Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following script within my functions.php file to avoid certain users from modifying things they shouldn't and would like to remove one more item, the Appearances > Themes submenu.

function remove_menus () {
global $menu;
    $restricted = array(__('Dashboard'), __('Posts'), __('Pages'), __('Comments'), __('Plugins'), __('Users'), __('Tools'), __('Links'), __('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)]);}
    }
}
add_action('admin_menu', 'remove_menus');

How would I be able to achieve this?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Use the API functions remove_menu_page and remove_submenu_page to remove menu items rather than manipulating global variables.

This will remove the themes page under appearance:

function wpa_remove_themes_submenu() {
    remove_submenu_page( 'themes.php', 'themes.php' );
}
add_action( 'admin_menu', 'wpa_remove_themes_submenu', 999 );
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.