Skip links

Disable Menus in WordPress Admin

On some occasion, We may find that when installing a new WordPress theme or plugin, new ones appear items in the administration menu that we are not going to use and that it is interesting to hide them.

Just like the popular phrase “All roads lead to Rome”, here we also have several options to do it.

The first option can be by installing a plugin. There are quite a few options but there is one called Admin Menu Editor para WordPress which is very simple to use and quick to manage as you can see in the attached image.

The second option, For example, it involves editing the file functions.php of your template and add the following code:


function remove_menus () {
global $menu;
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('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');

What we achieve in this case is to hide the links to the Desktop, Post-Entries, Multimedia, Links… in our list of menu options in the admin panel.

For example, to prevent the user from accessing depending on which administration menus we can make only the Posts show, Media and Pages eliminating these from the variable $restricted as indicated in this example:

$restricted = array(__('Dashboard'), __('Links'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));

This way, when you log in to the administration panel, you will only be able to modify the articles., media files gallery files and pages.

This is widely used in environments where we give the user/client access to the administration control panel, but we as webmasters, We do not want it to access other areas, preventing you from changing configuration options that could affect performance, web behavior or design.

Explore
Drag