Skip to content

WordPress admin panel custom landing page after login

Last updated on December 13, 2015

Redirect to different landing page after successful login on wordpress admin panel, if user not a super admin.

In your theme’s functions.php:

function your_login_redirect()
    {
      if(!is_super_admin()){
            return admin_url( 'edit.php' );
       } else {
          return admin_url();
       }       
    }
 
    add_filter( 'login_redirect', 'your_login_redirect');

Change default admin page for specific role(s)

function hide_the_dashboard()
{
    global $current_user;
    // is there a user ?
    if ( is_array( $current_user->roles ) ) {
        // substitute your role(s):
        if ( in_array( 'custom_role', $current_user->roles ) ) {
            // hide the dashboard:
            remove_menu_page( 'index.php' );
        }
    }
}
add_action( 'admin_menu', 'hide_the_dashboard' );
 
function your_login_redirect( $redirect_to, $request, $user )
{
    // is there a user ?
    if ( is_array( $user->roles ) ) {
        // substitute your role(s):
        if ( in_array( 'custom_role', $user->roles ) ) {
            // pick where to redirect to, in the example: Posts page
            return admin_url( 'edit.php' );
        } else {
            return admin_url();
        }
    }
}
add_filter( 'login_redirect', 'your_login_redirect', 10, 3 );
 
0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments