替换所有出现的$current_user->user_login == \'username\'
具有in_array(\'editor\', $current_user->roles)
. 您可以取消对的呼叫get_currentuserinfo();
至于用户信息,可从全局变量中获得$current_user
.
下面是代码交换:
add_action(\'_admin_menu\', \'remove_editor_submenu\', 1);
function remove_editor_submenu() {
global $current_user;
if(in_array(\'editor\', $current_user->roles)) {
remove_action(\'admin_menu\', \'_add_themes_utility_last\', 101);
}
}
add_action(\'admin_init\', \'remove_theme_submenus\');
function remove_theme_submenus() {
global $submenu, $current_user;
if(in_array(\'editor\', $current_user->roles)) {
unset($submenu[\'themes.php\'][5]);
unset($submenu[\'themes.php\'][7]);
unset($submenu[\'themes.php\'][15]);
}
}