# Redirect Users on Their First Login

> Sends each user to a welcome or onboarding page the first time they log in, and to the usual place after that.

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

## Code

```php
// Where first-time users go.
$wpide_first_login_url = home_url( '/welcome/' );

add_filter( 'login_redirect', function ( $redirect_to, $requested, $user ) use ( $wpide_first_login_url ) {
    if ( ! ( $user instanceof WP_User ) || get_user_meta( $user->ID, 'wpide_first_login_done', true ) ) {
        return $redirect_to;
    }

    update_user_meta( $user->ID, 'wpide_first_login_done', time() );

    return $wpide_first_login_url;
}, 30, 3 );
```

## Notes

Existing users count as first-timers on their next login after you activate this.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Redirect Users on Their First 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/
