0

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?

1 Answer 1

2

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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