There are plugins to redirect a user role to a specific page, but is there one that can redirect a username to a specific page?

I need userA to see only the page for userA. And userB to see only the page for userB, etc. All users would have the subscriber role but couldn't access one another's pages.

  • You can use Peter's Login Redirect for redirecting but you might have to write your own plugin or add the code to the theme to stop people from accessing each other page. wordpress.org/plugins/peters-login-redirect – JotDot Jan 6 '18 at 22:19

To redirect to a page, you can try this:

add_action( 'template_redirect', 'wpse_290317_redirect_user_to_page' );
function wpse_290317_redirect_user_to_page()
    $current_user = wp_get_current_user();
    if( 'username' == $current_user->user_login )
        wp_redirect( 'http://redirect-page-url' );

But I think you want to redirect on login, right? In that case, the following code should help:

add_action( 'login_redirect', 'wpse_290317_redirect_user_to_page', 999, 3 );
function wpse_290317_redirect_user_to_page( $redirect_to, $request, $user )
    if( 'username' == $user->user_login )
        $redirect_to = 'http://redirect-page-url';

    return $redirect_to;
  • Yes, I want to redirect on login. Your solution is very helpful. Thank you! – Mark Salvatore Jan 6 '18 at 22:27
  • Thank you, really helpful – SuperAtic Feb 16 at 22:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.