如果你想禁止某用户编辑个人资料我们可以参考下面方法,我们在当前主题的functions.php中添加以下代码:
代码如下:
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' );
当然,如果你使用前台的用户管理功能,以上方法就失效了.
if ( is_admin() ) {
$user = wp_get_current_user();
if ( 2 == $user->ID ) // 2 改成该用户的id
wp_die( '禁止访问' );
}
}
add_action( 'load-profile.php', 'disable_user_profile' );
当然,如果你使用前台的用户管理功能,以上方法就失效了.
希望本文所述对大家的WordPress建站有所帮助。
标签:WordPress
相关阅读 >>
更多相关阅读请进入《wordpress》频道 >>
相关推荐
评论
管理员已关闭评论功能...
- 欢迎访问木庄网络博客
- 可复制:代码框内的文字。
- 方法:Ctrl+C。