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

Multisite: Redirect Subsite Administrator to Subsite Home Page, Bypassing Dashboard

programmeradmin3浏览0评论

The subsite administrators of my multisite installation want to go directly to the subsite home page upon login, bypassing the dashboard. Irrespective of the wisdom of this, it's what they clearly want to do.

I have attempted to implement the suggestions found in the following two posts (among others) without success:

Multisite - Redirect All Users to Subsite Home Page on Subsite Login (including removing the "if (is_admin)" code ).

This seems like it should be straight-forward, but I am struggling. Any guidance would be most appreciated.

The subsite administrators of my multisite installation want to go directly to the subsite home page upon login, bypassing the dashboard. Irrespective of the wisdom of this, it's what they clearly want to do.

I have attempted to implement the suggestions found in the following two posts (among others) without success:

https://stackoverflow/questions/8127453/redirect-after-login-on-wordpress

Multisite - Redirect All Users to Subsite Home Page on Subsite Login (including removing the "if (is_admin)" code ).

This seems like it should be straight-forward, but I am struggling. Any guidance would be most appreciated.

Share Improve this question edited May 23, 2017 at 12:40 CommunityBot 1 asked Aug 25, 2014 at 18:26 mike31mike31 134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use the login_redirect filter:

add_filter( 'login_redirect', 'wpse_159078_login_redirect' );
function wpse_159078_login_redirect( $redirect ) {
    if( ! current_user_can( 'update_core' ) ) {
        // if it's not a super admin that's logging in
        $redirect = get_home_url();
    }
    return $redirect;

}

References

  • login_redirect filter
  • get_home_url()
发布评论

评论列表(0)

  1. 暂无评论