试试这个:
add_action(\'_admin_menu\', \'remove_editor_submenu\', 1);
function remove_editor_submenu() {
remove_action(\'admin_menu\', \'_add_themes_utility_last\', 101);
}
add_action(\'admin_init\', \'remove_theme_submenus\');
function remove_theme_submenus() {
global $submenu;
unset($submenu[\'themes.php\'][5]);
unset($submenu[\'themes.php\'][7]);
unset($submenu[\'themes.php\'][15]);
}
要禁用其他子菜单名称,请转至/wp管理/菜单。php并搜索要禁用的项目。
编辑:至于按用户名禁用,我将为角色添加一个新功能,并将其用作删除条件see here. 否则,只需使用您已经在使用的内容,如下所示:
add_action(\'_admin_menu\', \'remove_editor_submenu\', 1);
function remove_editor_submenu() {
global $current_user;
get_currentuserinfo();
if($current_user->user_login == \'username\') {
remove_action(\'admin_menu\', \'_add_themes_utility_last\', 101);
}
}
add_action(\'admin_init\', \'remove_theme_submenus\');
function remove_theme_submenus() {
global $submenu, $current_user;
get_currentuserinfo();
if($current_user->user_login == \'username\') {
unset($submenu[\'themes.php\'][5]);
unset($submenu[\'themes.php\'][7]);
unset($submenu[\'themes.php\'][15]);
}
}