TransWikia.com

Change wordpress admin home page

WordPress Development Asked by bendict mutua on October 30, 2021

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

One Answer

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.

Answered by mozboz on October 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP