removing dashboard menu options for the user role editor

Posted by styler on Stack Overflow See other posts from Stack Overflow or by styler
Published on 2012-03-23T23:25:10Z Indexed on 2012/03/23 23:29 UTC
Read the original article Hit count: 217

Filed under:
|

I want to remove some of the dashboard menu tabs on my wordpress site using this code:

//Remove some menu options
function remove_menus () {
global $menu;
    $restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Contact'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
    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');

At the moment this removes the menus from all user roles, how could I update this to just apply to editors?

Ive also got this snippet of code but dont know how to combine it with what I have:

$editor = get_role(‘editor’);
$editor->remove_cap(‘publish_pages’);

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress