The WPFolks app is out on iPhone. Free, no ads. Download on the App Store
Skip to main content
Login Join
Snippet · PHP

Redirect Users After WordPress Login

Shared by Amit Dholiya · September 23, 2026 · @login_redirect

5 views
1 upvote
Back to Snippets

You can automatically redirect users to a custom page after they successfully log in to your WordPress website. This is useful when you want users to land on a dashboard, account page, or another specific section instead of the default WordPress location.

Steps

  1. Add the code below to your theme’s functions.php.
  2. Change the destination URL.
  3. Save the changes.
  4. Log in to your WordPress website and test the redirect.
/**
 * Redirect users after WordPress login
 */
function custom_login_redirect( $redirect_to, $requested_redirect_to, $user ) {

    if ( ! is_wp_error( $user ) ) {
        return home_url( '/dashboard/' );
    }

    return $redirect_to;
}

add_filter(
    'login_redirect',
    'custom_login_redirect',
    10,
    3
);

Tested on

WordPress 7.1

Reported by the author on September 23, 2026. WPFolks has not verified this.

Know a different way to do this? Add your approach as a variation so folks can compare them side by side.
Submit a variation

0 comments