How to Remove WordPress Admin Menu Items for Specific User Roles?

So, you created a website for your customer and are afraid that he/she will be wondering around Plugins and Customizer messing something up? And now you need to know how to remove WordPress admin menu items for specific user roles? Good, because you’re in the right place.

In this post I’m going to show you two methods how to remove WordPress Admin Menu items. If you’re ready, then dive in. Before you dive in the code below, I would suggest you to take a look at the video here below. Otherwise, it may be a bit confusing what to use and how to use.

Video: How to Remove WordPress Admin Menu Items for Specific User Roles and Specific Users?

Method 1: Use Admin Menu Editor Plugin

Admin Menu Editor is a good and simple to use plugin which lets you manually edit the Dashboard menu. With the couple of clicks you can reorder the menus, show/hide specific items, change permissions etc. You can download it here.

If you need to remove admin menu item you would need to purchase a Pro version, though. Therefore, I’m going to show you how to to that by yourself with the help of couple of code snippets.

Method 2: Remove WordPress Admin Menu Items Programmatically

First, you need to decide whether you’re going to add the code snippet inside your child theme’s functions.php file or use plugin called Code Snippet for it.

I would suggest the Code Snippets option because you will not lose your modifiations in case you change theme, need to deactivate something etc.

One more thing, though – these snippets here below will just hide those menu items, they will not revoke access to the direct links. If you want to revoke the access then you would nee yo seek for another method.

How to Remove WordPress First Level Admin Menu Items?

Paste this part inside you Code Snipepts plugin. Pay attention to the comments inside the code because this will tell you which part of the code removes what. So, if you want to remove Posts menu, then just uncomment it and leave this part.

remove_menu_page( 'edit.php' ); //Posts

Now, this function here below will show you how to remove first level admin menu items (Comments, Plugins, Tools etc. Be reminded that if you hide first level menu then all the submenus will be automatically hidden. Also, this snippet will remove your Update submenu which is located under Dashboard menu

function hide_menu() {

   	 /* DASHBOARD */
	 // remove_menu_page( 'index.php' ); // Dashboard + submenus
   	 // remove_menu_page( 'about.php' ); // WordPress menu
   	 remove_submenu_page( 'index.php', 'update-core.php');  // Update 

   	 /* REMOVE DEFAULT MENUS */
	 remove_menu_page( 'edit-comments.php' ); //Comments
	 remove_menu_page( 'plugins.php' ); //Plugins
	 remove_menu_page( 'tools.php' ); //Tools
  	 remove_menu_page( 'users.php' ); //Users
  	 // remove_menu_page( 'edit.php' ); //Posts
	 // remove_menu_page( 'upload.php' ); //Media
	 // remove_menu_page( 'edit.php?post_type=page' ); // Pages
	 // remove_menu_page( 'themes.php' ); // Appearance
  	 // remove_menu_page( 'options-general.php' ); //Settings

}
add_action('admin_head', 'hide_menu');

If you have any 3rd party plugin related menus you need to remove then just add a new line, grab a last part of the menu URL and replace it inside the code. For Example: if I want to remove Elementor then the full URL is https://yoursite.com/wp-admin/admin.php?page=elementor

Grab the last part “elementor” and add it to the code like this:

remove_menu_page( 'elementor' ); 

How to Remove WordPress Admin Menu submenu Items?

This time we’re going to use remove_submenu_page with two part in it. See this code here below.

remove_submenu_page( 'options-general.php', 'options-writing.php');  

This code will remove Writing subenu (option-writing.php) which is located under Settings menu (options-general). So, if you want to remove submenu then you would need to change both parts inside the code. I know, it may be confusing but let me explain in the next chapter.

How to remove 3rd party plugin related menus or submenus?

I have a plugin called Fluent Forms installed and I want to remove submenu Global Settings. Now I will take a look at the Fulent forms first level menu item URL which is https://yousite.com/wp-admin/admin.php?page=fluent_forms (see the bold part? Write it down.)

Next I’ll grab a Global Settings submenu URL which is https://yoursite.com/wp-admin/admin.php?page=fluent_forms_settings (see the bold part? Write it down.)

Well, now you have both parts you would need to use in this code in order to remove Global Settings submenu:

remove_submenu_page( 'fluent_forms', 'fluent_forms_settings');  

How to remove WordPress Setting page menus and submenus?

Now, to make your life a bit easier here is a snippet which will give a good starting point. This will remove Setting page submenus. If you want to remove entire Settings menu (with submenus) then add this line to your sinppet.

remove_menu_page( 'options-general.php' ); //Settings

One again comment out or remove these lines you don’t want to remove and uncomment the ones you need to remove.

function hide_submenu() {

     	  /* REMOVE SETTINGS PAGE SUBMENUS */
  	// remove_submenu_page( 'options-general.php', 'options-permalink.php');  // Permalinks
  	   remove_submenu_page( 'options-general.php', 'options-writing.php');  // Writing
  	   remove_submenu_page( 'options-general.php', 'options-reading.php');  // Reading
  	   remove_submenu_page( 'options-general.php', 'options-discussion.php');  // Discussion
  	   remove_submenu_page( 'options-general.php', 'options-media.php');  // Media
  	// remove_submenu_page( 'options-general.php', 'options-general.php');  // General
  	   remove_submenu_page( 'options-general.php', 'options-privacy.php');  // Privacy

}
add_action('admin_head', 'hide_submenu');

How to Remove WordPress Customizer Admin Menu Item?

Probably it is not a wise idea to remove Appearance menu because you would also hide Widgets and Menus submenu items. Therefore, consider it carefully. Otherwise, if you want to remove submenus from Appearance add these lines inside one of the snippets you used above.

// remove_submenu_page( 'themes.php', 'widgets.php' ); // hide Widgets
// remove_submenu_page( 'themes.php', 'nav-menus.php' ); // hide Menus
   remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
   remove_submenu_page('themes.php', 'theme-editor.php'); // hide Theme editor

There is one more issue though – Customizer which need a bit different code snippet. But – I’ve got you covered. Just add this part inside your snippet.

$customizer_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
remove_submenu_page( 'themes.php', $customizer_url );

How to Remove WordPress Admin Menu Items for Specific User Roles?

Here’s the scenario for you.

  • You created a site for your customer
  • He/she needs access to the site
  • Customer need administrator rights but you don want him/her to access all the menus

So, what to do? Well, let’s create a new user role which has all admin rights but the role is called Site Admin.

How to Clone a WordPress Administrator user role?

It is easy. Just go to the Code Snippets and paste this code here below.

add_action('init', 'cloneRole');

function cloneRole() {
 $adm = get_role('administrator');
 $adm_cap= array_keys( $adm->capabilities ); //get administator capabilities
 add_role('site_admin', 'Site admin'); //create new role
 $new_role = get_role('site_admin');
  foreach ( $adm_cap as $cap ) {
   $new_role->add_cap( $cap ); //clone administrator capabilities to new role
  }
}

Press on “Save and activate” button and the role is cloned. Now you can delete this snippet.

How to Remove WordPress Admin Menu Items for Specific User Roles?

It is rather easy. Take a look at the role slug in the snippet we used to clone a role. There is a user role called Site admin and the slug is site_admin. Write it down because you’re gonna need it now.

Now, if you want to remove WordPress admin menu items for specific user role (Site Admin, for example) then you would need to modify your snippet a bit. Something like this:

function hide_siteadmin() {
  
// Use this for specific user role. Change site_admin part accordingly
if (current_user_can('site_admin')) {

   /* DASHBOARD */	
   remove_submenu_page( 'index.php', 'update-core.php');  // Update
    }
}
add_action('admin_head', 'hide_siteadmin');

As you see, we removed Update submenu for Site admin user role.

How to Remove WordPress Admin Menu Items for Specific Users?

Once again, this is fairly easy. This time you would need to modify your snippet to look like this one here below.

function hide_demouser() {
  
//  Change username "demouser"
 $user = wp_get_current_user();
    if($user && isset($user->user_login) && 'demouser' == $user->user_login) { 

   /* DASHBOARD */	
   remove_submenu_page( 'index.php', 'update-core.php');  // Update
    }
}
add_action('admin_head', 'hide_demouser');

Let put everything together

If everything I described here is a bit confusing then just grab this code here below and remove the lines you don’t need. It contains everything I showed you above and remove menu items for Site Admin user role. Inside the code there is a commented out part for Demouser.

As a bonus I included some examples for the well-known plugin menus you may want to remove.

function hide_menu() {
  
// Use this for specific user role. Change site_admin part accordingly
if (current_user_can('site_admin')) {
  
// Uncomment the part below if you need it to specific user. Change username "demouser"
/* $user = wp_get_current_user();
    if($user && isset($user->user_login) && 'customer' == $user->user_login) { */
   
   	/* DASHBOARD */
	// remove_menu_page( 'index.php' ); // Dashboard + submenus
   	// remove_menu_page( 'about.php' ); // WordPress menu
   	remove_submenu_page( 'index.php', 'update-core.php');  // Update
 		
   	/* WP DEFAULT MENUS */
	 remove_menu_page( 'edit-comments.php' ); //Comments
	 remove_menu_page( 'plugins.php' ); //Plugins
	 remove_menu_page( 'tools.php' ); //Tools
  	 remove_menu_page( 'users.php' ); //Users
  	 // remove_menu_page( 'edit.php' ); //Posts
	 // remove_menu_page( 'upload.php' ); //Media
	 // remove_menu_page( 'edit.php?post_type=page' ); //Pages
	 // remove_menu_page( 'themes.php' ); //Appearance
  	 // remove_menu_page( 'options-general.php' ); //Settings

   	  /* SETTINGS PAGE SUBMENUS */
  	//remove_submenu_page( 'options-general.php', 'options-permalink.php');  // Permalinks
  	  remove_submenu_page( 'options-general.php', 'options-writing.php');  // Writing
  	  remove_submenu_page( 'options-general.php', 'options-reading.php');  // Reading
  	  remove_submenu_page( 'options-general.php', 'options-discussion.php');  // Discussion
  	  remove_submenu_page( 'options-general.php', 'options-media.php');  // Media
  	//remove_submenu_page( 'options-general.php', 'options-general.php');  // General
  	  remove_submenu_page( 'options-general.php', 'options-privacy.php');  // Privacy
  
      /* APPEARANCE SUBMENUS */
      // remove_submenu_page( 'themes.php', 'widgets.php' ); // hide Widgets
      // remove_submenu_page( 'themes.php', 'nav-menus.php' ); // hide Menus
	 remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
 	 remove_submenu_page('themes.php', 'theme-editor.php'); // hide Theme editor
   
  /* HIDE CUSTOMIZER MENU */
  $customizer_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
  remove_submenu_page( 'themes.php', $customizer_url );

   /* Plugin related submenus under Settings page */
   remove_submenu_page( 'options-general.php', 'webpc_admin_page' ); // WebP converter
   remove_submenu_page( 'options-general.php', 'kadence_blocks' ); // Kadence Blocks
     
	  /* 3rd party plugin menus */
	  // remove_menu_page( 'snippets' ); // Code snippets
	  // remove_menu_page( 'elementor' ); // Elementor
	  // remove_menu_page( 'rank-math' ); // Rank Math
	  // remove_menu_page( 'Wordfence' ); // Wordfence
	  // remove_menu_page( 'WPML' ); // WPML
   	  // remove_menu_page( 'fluent_forms' ); // Fluent Forms
  	  // remove_menu_page( 'ct-dashboard' ); // Blocksy
    }
      }
add_action('admin_head', 'hide_menu');

How to Remove WordPress Admin Bar Items?

One more thing. Although you removed menu items from the WordPress Admin there is a small problem. That is: customizer menu item is still visible on front-end admin bar. So, if you want to remove Worpress admin bar items then this snippet will remove some of them for Site Admin user role.

// Remove frontend admin bar items
function remove_admin_bar_items($wp_admin_bar) {
    if (current_user_can('site_admin')) {
        // Plugin related admin-bar items
        $wp_admin_bar->remove_node('blocksy_preview_hooks');
        // WordPress Core Items 
        $wp_admin_bar->remove_node('updates');
        $wp_admin_bar->remove_node('comments');
        // $wp_admin_bar->remove_node('new-content');
        $wp_admin_bar->remove_node('wp-logo');
        //$wp_admin_bar->remove_node('site-name');
        //$wp_admin_bar->remove_node('my-account');
        //$wp_admin_bar->remove_node('search');
        $wp_admin_bar->remove_node('customize');
    }
}
add_action('admin_bar_menu', 'remove_admin_bar_items', 999);

Here are some of my favorite Wordpress tools

Thank you for reading this article. I hope you found it helpful as you build your own websites and e-commerce sites. Here are some tools I use as a Wordpress developer and enthusiast that I hope you’ll also find helpful.

These are affiliate links, so if you do decide to use any of them, I’ll earn a commission and this helps me create these tutorials and make Youtube videos. But in all honesty, these are the exact tools that I use and recommend to everyone, even my friends and family.

Themes: For the last couple of years I have two go-to themes which I use for every kind of projects. Those two themes are Blocksy theme and Kadence Theme. On this site and my Youtube channel you’ll see a lot of tutorials I have made about them. If you would like to get a 10% discount for both of them then:

Contact forms: There are hundreds of contact forms out there but Fluent Forms is the one I like the most. If you need a 20% discount then use this link (save 20% coupon is WPSH20).

Gutenberg add-ons: If I need a good Gutenberg blocks add-on then Kadence Blocks is the one I have used the most. You’ll get 10% discount with the coupon SIMPLEHACKS here.

Website migration: While building a website you probably need a good plugin that can help you with the migration, backups, restoration and staging sites. Well, WpVivid is the one I have used for the last couple of years. If you use this link along with the WPSH20 coupon you’ll get 20% discount.

Woocommerce extensions: There are a bunch of Woocommerce extensions that I really like but the one that stands really out is Advanced Dynamic Pricing. Once again, you’ll get a 20% discount if you use this link here (save 20% coupon is WPSH20)

Web Hosting: For getting started, I really like A2 Hosting. They have the dedicated and fast Wordpress hostinh and support has also been fast and responsive. If you’re more tech savvy and want to have a really fast managed cloud hosting then I recommend Cloudways. (Btw, this site is hosted in Cloudways.)

To see all my of most up-to-date recommendations, check out this resource that I made for you!

Do you want to thank me and buy me a beer?

Every donation is entirely welcome but NEVER required. Enjoy my work for free but if you would like to thank me and buy me a beer or two then you can use this form here below.

Choose amount

Best selling plugins

Default image
Janek T.
I am a Wordpress enthusiast who has been making websites since 2011. In this site I am offering simple to follow tips on how to use Wordpress and Woocommerce. If you want to be the first to be notified about the new tutorials then please subscribe to my Youtube channel here Follow me in Twitter here
Articles: 72