So I found some handy snippets to help remove admin menu items. However, I’m having trouble with the sub menu items. I want to keep the appearance menu, but get rid of the Themes, Widgets, and Editor.
function remove_menus()
{
global $menu;
global $current_user;
get_currentuserinfo();
if($current_user->user_login == 'username')
{
$restricted = array(__('Posts'),
__('Links'),
__('Comments'),
__('Plugins'),
__('Users'),
__('Tools'),
__('Settings')
);
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
{unset($menu[key($menu)]);}
}// end while
}// end if
}
add_action('admin_menu', 'remove_menus');
function remove_submenus()
{
global $menu;
global $current_user;
get_currentuserinfo();
if($current_user->user_login == 'username')
{
global $submenu;
unset($submenu['themes.php'][10]); // remove the theme editor
}
}
add_action('admin_menu', 'remove_menus');
Try this:
To disable other submenu names, go to ./wp-admin/menu.php and search for the item(s) you want to disable.
EDIT: As far as disabling by username, I would instead add a new capability to a role and use that as your removal condition see here. Otherwise, just use what you already were using, like so:
There are much simpler functions for removing menu and submenu pages since 3.1:
remove_menu_page() and remove_submenu_page()
however, the issue with removing themes is that the appearance menu IS the themes page.
EDIT- what you can do is remove the entire appearance menu, then create a new top level menu item using add_menu_page()