0

I would like to change the /wp-admin/index.php default page to something like /wp-admin/edit.php?post_type=page so that when a user logs in, they get redirected to /wp-admin/edit.php?post_type=page instead of /wp-admin/index.php. I will appreciate guides on this

0

There's a filter called login_redirect where you can change the URL users get redirected to after logging in.

There's a nice example in the comments of the documentation page here: https://developer.wordpress.org/reference/hooks/login_redirect/

Here's a suggestion of how you could modify it to do what you want:

function wpdocs_my_login_redirect( $url, $request, $user ) {
    if ( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
        if ( $user->has_cap( 'administrator' ) ) {
            $url = home_url('/YOUR/CUSTOM/URL/HERE');
        } 
    }
    return $url;
}

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

Note this code untested, let me know if you try it and have problems.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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