Archived topic
Hide admin menu for admin users EXCEPT user id 1
3 replies · Started by melvin on July 23, 2021
Hi,
I would like to hide admin menu for all admin users EXCEPT user id 1. I tried the below code it seems fail,
// Hide admin menu for admin users EXCEPT user id 1
if (current_user_can('administrator') && !$user_id == '1') {
function hide_menu_admin() {
/* REMOVE SUB MENU ITEMS*/
remove_submenu_page( 'plugins.php', 'plugin-editor.php' ); // Plugin Editor
remove_submenu_page( 'themes.php', 'theme-editor.php' ); // Theme Editor
}
}
add_action('admin_head', 'hide_menu_admin');
Could you kindly guide me the correct way?
TQ
Melvin
Hi there,
Would it work if you replace == with != as seen in the second solution here?
https://stackoverflow.com/questions/42934129/hiding-admin-menu-items-in-wordpress
If not then please check with WordPress support team.
Thanks!
Hi leo,
Thanks for your fast response, after i read the guide https://stackoverflow.com/questions/42934129/hiding-admin-menu-items-in-wordpress i used the first method and it works!
Thanks
No problem :)