让WordPress默认用户无法进入后台

让WordPress的默认角色用户无法进入后台

//让WordPress的默认角色用户无法进入后台
if ( is_admin() && ( !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() );
    exit();
  }
}

 注册成功后跳转到指定页面

// 注册成功后跳转到指定页面
function __my_registration_redirect() {
  // 这里设置的是跳转到首页,要换成其他页面
  // 可以将home_url()改成你指定的URL
  // 如 return 'http://www.baidu.com';
  return home_url();
}
add_filter( 'registration_redirect', '__my_registration_redirect' );

 

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 共2条

请登录后发表评论

    • 头像我是菜b0