一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

WordPress禁止指定用户编辑个人资料

时间:2013-03-30 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码
function disable_user_profile() {
  if ( is_admin() ) {
    $user = wp_get_current_user();
    if ( 2 == $user->ID )  // 2 改成该用户的id
      wp_die( '禁止访问' );
  }
}
add_action( 'load-profile.php', 'disable_user_profile'

);

如果你使用前台的用户管理功能,以上方法就失效了。

上面都是固定好了,如果有N个我们可以使用数据库的来操作了。

热门栏目