# Send Non-Editors to the Homepage After Login

> Users who cannot edit posts (subscribers, customers) land on the homepage after logging in instead of their admin profile. Staff still go to the dashboard.

- Type: PHP
- Runs: Run everywhere
- Category: [Login](https://wpide.com/library/category/login/)
- Tags: login, redirect, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/login-redirect-by-role/

## Code

```php
add_filter( 'login_redirect', function ( $redirect_to, $requested, $user ) {
    if ( ! $user instanceof WP_User || user_can( $user, 'edit_posts' ) ) {
        return $redirect_to;
    }

    // Respect explicit front-end destinations such as a "log in to comment" link.
    if ( $requested && false === strpos( $requested, admin_url() ) ) {
        return $redirect_to;
    }

    return home_url( '/' );
}, 10, 3 );
```

## Notes

Replace home_url( '/' ) with any URL, for example home_url( '/account/' ).

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Send Non-Editors to the Homepage After Login" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
