最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Change wordpress admin home page

programmeradmin6浏览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

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

Share Improve this question asked Jul 21, 2020 at 5:51 bendict mutuabendict mutua 213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

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/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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论