I am trying to remove the Events sidebar menu in the admin screen so contributors can’t add or edit events. I used the following code but it didn’t work:
function remove_menus () {
global $menu, $current_user;
if(in_array(‘contributor’, $current_user->roles) )
{
$restricted = array(__(‘Events’));
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’);