Wordpress自定义MU插件获取用户详细信息

Wordpress自定义MU插件获取用户详细信息,wordpress,Wordpress,我希望你能帮忙 我有一个wordpress multisite,它带有一个自定义登录名,默认情况下会将用户带到根wp管理员,这会为那些没有正确权限的用户提供此错误 You attempted to access the "WordPress" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "WordPress" da

我希望你能帮忙 我有一个wordpress multisite,它带有一个自定义登录名,默认情况下会将用户带到根wp管理员,这会为那些没有正确权限的用户提供此错误

You attempted to access the "WordPress" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "WordPress" dashboard, please contact your network administrator.
我希望他们像这个例子一样被重定向到主博客

但是,我的mu插件中的自定义插件不包含$current_user,也不包含任何使当前用户工作的函数。
我构建的其他函数都可以正常工作,因此我知道包含该文件并没有什么问题。

我最终找到了答案。 我希望这对某人有帮助

function check_if_user_needs_redirecting(){
    $active_blog = get_active_blog_for_user(get_current_user_id());
    $blogid = get_current_blog_id();
    if ($blogid != $active_blog->blog_id){
        header('Location: '.$active_blog->siteurl.'/wp-admin/');
        exit;
    }
}
add_action( 'init', 'check_if_user_needs_redirecting' );

似乎是一个非常糟糕的解决方案,在每个WP页面(前端和后端,甚至Ajax)都运行它。如果您在问题中发布自定义登录的详细信息,可能有更好的解决方案。