很好的回答,这是一个更进一步的步骤,适用于任何希望将此应用于所有非管理员用户(例如,贡献者、编辑等)的人
// ===== remove edit profile link from admin bar and side menu and kill profile page if not an admin
if( !current_user_can(\'activate_plugins\') ) {
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(\'edit-profile\', \'user-actions\');
}
add_action( \'wp_before_admin_bar_render\', \'mytheme_admin_bar_render\' );
function stop_access_profile() {
if(IS_PROFILE_PAGE === true) {
wp_die( \'Please contact your administrator to have your profile information changed.\' );
}
remove_menu_page( \'profile.php\' );
remove_submenu_page( \'users.php\', \'profile.php\' );
}
add_action( \'admin_init\', \'stop_access_profile\' );
}