2020-04-21 / 5629阅
如果我们自己做了会有中心,或者没有会有功能,那么不需要用户访问后台,我们可以通过以下代码实现
function qzl_redirect_wp_admin()
{
if ( is_admin() && !current_user_can('editor') && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {
$current_user = wp_get_current_user();
if($current_user->roles[0] == get_option('default_role')) {
wp_safe_redirect( home_url('/user') );
exit();
}
}
}
add_action('init', 'qzl_redirect_wp_admin'); 阅读文章或者观看视频过程中有任何问题,请下方留言或者联系我Q248758228