Remove or Hide Menu Items from WordPress Admin Panel or Dashboard

You often need to remove or hide menu items from WordPress admin panel or dashboard. This is a common requirement if you develop WordPress websites for clients or manage multi-user blog.

You will learn how to remove menu items from WordPress admin panel. You will also learn the same for submenus. Further, I will also explain how can you hide menu items based on user Id or capability. Please note that all the examples are for WordPress version 3.1 and above.

Hide Menu Items from WordPress Admin

Hide Menu Items – Requirements and Benefits

Wisely limiting menu items in admin panel not only easier things for clients but also offers numerous advantages. This involves productivity, safety, comfort and control. The next few paragraphs explain them in details if you hide menu items from WordPress admin panel.

You might like: Making mega menu with WordPress and Bootstrap 4

If you’re using a premium theme, it already comes with a number of additional menus and custom post types. You or your client might not always need them. For example, you might need the portfolio, gallery, testimonial or event CPTs but not all on one website. It’s better to remove such unnecessary menu items from WordPress dashboard for a cleaner workspace.

Second, you don’t want every logged in user to play with settings or themes within the admin panel. Hide menu items from them. Keep your work away from them as well as secure the site in this way.

Further, few users complain that WordPress dashboard doesn’t look like a dedicated eCommerce dashboard. If you remove unnecessary menus and widget then you also overcome this complaint heavily.

Hide Menu or Submenu Items

The remove_menu_page() and remove_submenu_page() functions are what we need to remove the menus. Both functions return an array upon success and false in case the menu doesn’t exist. Check the following scripts below.

Remove a Menu

So here you see all the default menu slugs available in WordPress dashboard. Hide specific menu items which you don’t need in the admin panel. If you’re removing Jetpack menu, pass 999 as the third parameter in the add_action() hook call for priority.

You have to copy-paste the code snippet in your theme’s function.php file and make necessary changes.

Hide a Submenu

Hiding a submenu is little different from hiding a menu item. You require providing parent page slug as well as submenu page slug. Later we have commented the output if you wish to see the returned array.

Make your WordPress website faster using Transient API

Some dashboard URLs contain file name followed by query string parameters. In such case, use the value from page parameter in the URL as shown.

Hide Menu Items Based on User or Capability

Sometimes it requires hiding menu items for a specific user ID or set of IDs. You might even need to remove menus for one among many users with the same capability. The following script demonstrates how can you implement the same.

It’s also possible to hide menus by user role. Unfortunately, there is currently no WordPress function to fetch user’s role directly. So you have to first obtain user info then roles and finally check each role. I will publish an article soon to easier this task.

You can compare with email instead if user ID as well. At the end of the article, I have provided some references. I encourage you to read them for alternative or granular selection.

Hide Menu Items from WordPress Admin Panel

Note that removing menus from dashboard doesn’t mean the user can’t access them directly by typing URL in address bar. In other words, removing a menu doesn’t change the user’s capability in the admin panel. You have to play with user roles and capabilities to restrict. However, it’s a broad topic and we will cover it some other day.

From start to finish: WordPress Custom Post Types and Fields

There are few plugins too to control the menus as well as user capabilities. However, as we’re coding guys, we prefer coding than installing and configuring for non-complex requirements. Still, we have listed a few useful plugins below to hide unnecessary items from users in WordPress admin.

 

We haven’t tested either of them. If your requirements are wide or you’re not a coding guy, try these plugins. Have any question or feedback regarding hiding menu items? Comment in the form below and let us assist you.

You Might Interested In

1 COMMENT

  1. Andy Globe says:

    I have comments deactivated in adminimize in the menu options but it stil shows up on the admin screen for all users. I would like only admins and editors to see the comments.

    Reply

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.