The Basics
Menu permissions are based on capabilities. To hide a menu item from a role or a user, you need to set the “extra capability” field to a capability that the role or user doesn’t have.
For example, let’s say you want to hide a menu from everyone who’s not an Administrator. Take a look at the role vs. capability table. You’ll see that there are several capabilities that are exclusive to the Administrator role, like “manage_options”, “activate_plugins”, “switch_themes” and so on. Change “extra capability” to any of these options to hide it from non-administrator users.
To make it easier to find the right capability, the plugin provides some automated recommendations. Click the down arrow that’s to the right of the “extra capability” field to display all available roles, capabilities, and the suggestion table.
For every role, the “Suggestion” column (on the right) shows a capability that the roles below it do not have. You can mouse over a capability name to see which roles would be able to access the menu with that capability selected. The roles that have both the extra capability and the required capability will be highlighted in green.
Please note that the suggestions are generated automatically and might not always be the best fit for your needs. Also, if you have custom roles that can’t be arranged in a strict hierarchical order, you might get overlapping suggestions.
Advanced Topics
Hiding Top Level Menus
To hide a top level menu, you also need to hide all of its submenu items. This is just a quirk of how admin menus work in WordPress. A top level menu will stay visible as long as it has at least one visible menu item.
Using a Role as the Extra Capability
You can set “extra capability” to a role ID instead of a capability. This will hide the menu from all users users who don’t have that particular role. For example, changing the setting to “editor” will hide the menu from all other roles, even from Administrator.
Giving a Role Access to a Menu
Unfortunately, it’s not possible to use these settings to give a role access to a menu item that it normally wouldn’t be able to see. You can use extra capabilities to create additional restrictions on who can see which menus, but you can’t override the access requirements that are already in place. This is because the required capability is usually hard-coded in the plugin or theme that created the menu item, so you can’t change it without editing the source code.
To allow access to a menu, you could:
- Give the role the required capability. You can do that with any role management plugin. Here are some free options, in no particular order:
- Get the Pro version of Admin Menu Editor. It shows a checkbox for each menu item. When you check an item, the plugin automatically assigns the required capability to the selected role, making the menu item visible.
Troubleshooting
What if you’ve changed the extra capability but the menu item is still visible? Here are some things to check:
- Is it a top level menu? Make sure all of its submenus are hidden. As mentioned before, a top level menu will stay visible as long as it has any visible submenu items.
- Compare the menu URLs that you see when logged in as different users. As an administrator, do you see the same URL as the user that you’re trying to hide things from? Admin Menu Editor identifies menus by their URL. If the URLs don’t match, chances are that you won’t be able to hide that particular menu.
- Enable debug logging. Note: The log will be visible to all logged-in users, so you might want to avoid doing this on a live site.
- Go to the “Settings” tab in the menu editor.
- Check this box: “Show menu access checks performed by the plugin on every admin page”.
- Save changes. You will now see a large block of text at the top of every admin page.
- Log in as the user whose menu you’re trying to customize.
- Click the menu that you want to hide.
- Examine the log for clues. Does it show the correct menu title and URL? Does it show the roles that you expected? Does it mention the extra capability you’ve selected?
- Turn off logging.
- Contact me. Please include:
- The name of the menu item.
- The name and homepage of the plugin or theme that created this item.
- The role(s) that you were trying to customize and the capabilities that you selected.
- The debug log, if any.