Need to whip menu items into shape in the WordPress Admin dashboard? Accessing that section is one of the primary ways of managing your website behind the scenes. Combined with enough users in proper user roles and the ability to log in to FTP (File Transfer Protocol) or SFTP (Secure FTP), the functionality is a backbone of every successful site. However, installing a plethora of plugins and making changes may make the sidebar menu too plentiful and thus unorganized and confusing. Additionally, you may want some users to only have access to a few menu items, while others get them all. Here’s how to hide WordPress Admin menu items.
Reasons to clean up items from a WordPress menu
The administrator menu on the left-hand side of the WordPress back-end has a lot of items, menus, submenus, options, widgets, post and page sections, and theme and plugin settings. As mentioned, you may want writers, contributors, editors, and other administrators to have limited access. That is especially important on a multisite network or any multi-author website. When things are cleaned up, you improve workflow by optimizing available choices. Simultaneously, you prevent users from abusing options they shouldn’t have access to.
1. Hide menu items in WordPress Admin via PHP
Before we start explaining this method, you need to know how to check the user ID in WordPress. That lets you remove some menu pages for some users or roles while keeping them for others. Here are three examples:
add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
global $user_ID;
if ( $user_ID != 123 ) { // Enter the user ID instead of 123
remove_menu_page('edit.php'); // Posts
remove_menu_page('users.php'); // Users
remove_menu_page('plugins.php'); // Plugins
remove_menu_page('themes.php'); // Appearance
remove_menu_page('tools.php'); // Tools
remove_menu_page('options-general.php'); // Settings
remove_menu_page('upload.php'); // Media
remove_menu_page('link-manager.php'); // Links
remove_menu_page('edit-comments.php'); // Comments
remove_menu_page('edit.php?post_type=page'); // Pages
}
}
The code above, when added to functions.php, into a code snippet plugin, or using a site-specific plugin, will hide all the menu items on the list for the user whose ID you provided. Check our theme editing guide for more information. If that seems bulky, and you can’t figure out how to acquire the ID, we propose using the e-mail address tied to the account.
function custom_menu_page_removing() {
if ( get_currentuserinfo()->user_email != 'some.user@emailprovider.com' )
remove_menu_page( 'edit.php' );
remove_menu_page( 'tools.php' );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );
You can also remove all unused menu items for all users using the following function:
function remove_item_from_menu() {
remove_menu_page( 'edit.php?post_type=elementor_library' ); // eradicates Elementor addons menu item
remove_menu_page( 'edit-comments.php' ); // removes comment menu if you disabled them anyway
}
add_action( 'admin_init', 'remove_item_from_menu' );
2. Using a WordPress plugin to hide menu items
We know not all users are savvy with CSS, and prefer not to alter their site files directly. As usual, those users have an alternative—installing a WordPress plugin. Now, there are several creations on the repository that let you do this, and we have no preference or ties to the developers. Therefore, we’ll demonstrate two that use a slightly different method.
1. Concealing items in the sidebar via Admin Menu Editor
Admin Menu Editor by Janis Elsts seems to be the most popular free plugin that lets you switch menu titles, positions, icons, and names. You can also create a custom menu item that points to any other, and, what we seek, hide or show individual items. Most importantly, it’s straightforward to use and works this way:
- Install and activate the plugin.
- Expand the left sidebar and click the Menu Editor option under “Settings”.
- Preview the existing menu items on the left side, under “Dashboard”.
- You can now click any entry to open the editing tab for each item. Similarly, you can click, then drag and drop to rearrange positions.
- Hiding menu items requires you to click the Extra capability, and select the user role (administrator, writer, editor, and so on) that can see the entry. If you only want designers to see Theme options, select that role. Selecting multiple roles requires you to sign up for a Pro version.
- Once you’re finished, click the Save Changes button. Do that as many times as you need.
- Test whether that works. Users without permissions shouldn’t see the option. If they somehow open it via a direct URL, they get a “You do not have sufficient permissions to access this admin page.”
2. Employ WP Custom Admin Interface
WP Custom Admin Interface by Martin Gibson is equally simple for beginners, yet drastically more powerful if you know PHP, CSS, and JavaScript. After installation and activation, do this:
- Click the newly introduced Custom Admin Interface option in the left sidebar.
- On the list of options in a new tab, click Customize Admin Menu.
- You can now drag and drop items like above, and determine which submenu items will appear. Most importantly, you can click the crossed-out eye on the right-hand side to hide any entry. The option for concealing items from some roles is there, too.
- Clicking the Add menu item option at the top lets you insert new ones, and you can restore them from a backup. Applying advanced changes via JS, CSS, and PHP requires you to click the edit icon (feather) and start typing.