I want to restrict access to certain plugin pages / normal WP Pages. I've found a way to Hide these pages from the menu but currently not restrict them. For instance, I have an editor and I don't want them to have access to Media
and Tools
- I can hide those pages via this:
function editor_menu() {
global $menu;
if(!current_user_can('administrator'))
{
$restricted = array(__('Media'),__('Tools'));
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', 'editor_menu', 999);
But how can I restrict them from viewing this page entirely? Like permissions?