Customize the WordPress admin menu based on user roles

WordPress can be a powerful content management system but if you have multiple users often some can end up with permissions that you really wish they didn’t have. There are plenty of plugins that will let you customize user permissions but it’s not that hard to do ourselves by removing certain links from the admin menu for those specific user roles.

Note that this method doesn’t actually remove user permissions but hides the links in the dashboard that would get them there.

Basic example

Add the following to functions.php (or create your own plugin) to remove the “Tools” menu from any user with a role lower than Author.

add_action( 'admin_init', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
	// If the user does not have access to publish posts
	if(!current_user_can('publish_posts')) {
		// Remove the "Tools" menu
		remove_menu_page('tools.php');
	}
}

Removing the Tools menu

You can choose a variety of user levels rather than publish_posts for example edit_users, delete_pages, etc. View a complete list of WordPress roles and capabilities.

The function remove_menu_page() removes a menu item based off of the menu slug you pass it. To figure out that the menu slug was named tools.php I used used Chrome’s developer tools and right clicked on the Tools menu and selected Inspect element. This showed me that the tools menu was linked as <a href="tools.php" tabindex="1">Tools</a>.

To save you the hassle of figuring out each menu slug I listed them below.

Removing sub-menu items

add_action( 'admin_init', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
	// If the user does not have access to add new users
	if(!current_user_can('add_users')) {
		// Remove the "Link Categories" menu under "Links"
		remove_submenu_page( 'link-manager.php', 'edit-tags.php?taxonomy=link_category' );
	}
}

Removing the Tools menu

The function remove_submenu_page() is similar but takes two arguments, the parent menu’s slug and the sub-menu’s slug. Once again you can find the slugs by inspecting each menu link or view the complete list below.

Mixed example

add_action( 'admin_init', 'my_remove_menu_pages' );

function my_remove_menu_pages() {
	if(!current_user_can('add_users')) {
		remove_menu_page('options-general.php'); // Settings
		remove_menu_page('tools.php'); // Tools
		remove_menu_page('upload.php'); // Media

		remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=category' ); // Post categories
		remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=post_tag' ); // Post tags
	}
}

WordPress admin menu slugs

Dashboard remove_menu_page(‘index.php’);
Dashboard remove_submenu_page( ‘index.php’, ‘index.php’ );
Updates remove_submenu_page( ‘index.php’, ‘update-core.php’ );

Posts remove_menu_page(‘edit.php’);
Posts remove_submenu_page( ‘edit.php’, ‘edit.php’ );
Add New remove_submenu_page( ‘edit.php’, ‘post-new.php’ );
Categories remove_submenu_page( ‘edit.php’, ‘edit-tags.php?taxonomy=category’ );
Post Tags remove_submenu_page( ‘edit.php’, ‘edit-tags.php?taxonomy=post_tag’ );
Media remove_menu_page(‘upload.php’);
Library remove_submenu_page( ‘upload.php’, ‘upload.php’ );
Add New remove_submenu_page( ‘upload.php’, ‘media-new.php’ );
Links remove_menu_page(‘link-manager.php’);
Links remove_submenu_page( ‘link-manager.php’, ‘link-manager.php’ );
Add New remove_submenu_page( ‘link-manager.php’, ‘link-add.php’ );
Link Categories remove_submenu_page( ‘link-manager.php’, ‘edit-tags.php?taxonomy=link_category’ );
Pages remove_menu_page(‘edit.php?post_type=page’);
Pages remove_submenu_page( ‘edit.php?post_type=page’, ‘edit.php?post_type=page’ );
Add New remove_submenu_page( ‘edit.php?post_type=page’, ‘post-new.php?post_type=page’ );
Comments remove_menu_page(‘edit-comments.php’);

Appearance remove_menu_page(‘themes.php’);
Themes remove_submenu_page( ‘themes.php’, ‘themes.php’ );
Widgets remove_submenu_page( ‘themes.php’, ‘widgets.php’ );
Menus remove_submenu_page( ‘themes.php’, ‘nav-menus.php’ );
Editor remove_submenu_page( ‘themes.php’, ‘theme-editor.php’ );
Plugins remove_menu_page(‘plugins.php’);
Plugins remove_submenu_page( ‘plugins.php’, ‘plugins.php’ );
Add New remove_submenu_page( ‘plugins.php’, ‘plugin-install.php’ );
Editor remove_submenu_page( ‘plugins.php’, ‘plugin-editor.php’ );
Users remove_menu_page(‘users.php’);
Users remove_submenu_page( ‘users.php’, ‘users.php’ );
Add New remove_submenu_page( ‘users.php’, ‘user-new.php’ );
Your Profile remove_submenu_page( ‘users.php’, ‘profile.php’ );
Tools remove_menu_page(‘tools.php’);
Tools remove_submenu_page( ‘tools.php’, ‘tools.php’ );
Import remove_submenu_page( ‘tools.php’, ‘import.php’ );
Export remove_submenu_page( ‘tools.php’, ‘export.php’ );
Settings remove_menu_page(‘options-general.php’);
General remove_submenu_page( ‘options-general.php’, ‘options-general.php’ );
Writing remove_submenu_page( ‘options-general.php’, ‘options-writing.php’ );
Reading remove_submenu_page( ‘options-general.php’, ‘options-reading.php’ );
Discussion remove_submenu_page( ‘options-general.php’, ‘options-discussion.php’ );
Media remove_submenu_page( ‘options-general.php’, ‘options-media.php’ );
Privacy remove_submenu_page( ‘options-general.php’, ‘options-privacy.php’ );
Permalinks remove_submenu_page( ‘options-general.php’, ‘options-permalink.php’ );

About Seth

Digital marketer and web professional from Des Moines, IA.

61 Comments

  1. ferry on June 16, 2011 at 10:12 pm

    hey thanks, i really need this,why you dont make plugin for this function,..

  2. sebin on August 11, 2011 at 2:28 am

    Thanks a lot!!!
    Really usefull stuff

    • jual sambal roa manado on September 5, 2017 at 3:35 am

      Thank You Messages for Dad: Father’s Day and birthdays will come and go, but family is forever. So pick a random day to say Thank You to the man who loves …

  3. sebin on August 11, 2011 at 2:28 am

    Thanks a lot!!!
    Really useful stuff

  4. Trent - Wordpress Consultant on September 4, 2011 at 1:06 am

    Great work on this! Just the plugin I was looking for to customize the WordPress admin area. Thanks!

  5. Zoinks! Graphics on September 4, 2011 at 3:31 pm

    Awesome list, glad you posted it! Do you know if there’s a way to query WP for a list of the menu and submenu slugs, and also plugin menu slugs? I’m worried about hard-coding the slugs in your list, then WP changing them in a few months. So obviously I’d like something future-proof, if that’s possible? Otherwise I’m’a work from your list for now…

  6. simon on October 22, 2011 at 8:12 am

    Thanks for this info.
    How to I remove submenu for custom post_types?
    For example I want to retain the post tags meta box in the admin page but want to remove the ‘Post Tags’ link from the submenu

  7. Chritchan on November 14, 2011 at 4:56 pm

    OMG ! Realy need this, Great tutorial !

  8. Jarski on January 20, 2012 at 3:28 pm

    And what if somebody goes with direct url? I think we need some .htaccess to redirect them.

    • Seth Stevenson on January 20, 2012 at 11:29 pm

      Yes this method doesn’t actually remove the user permissions. For that you might try a plugin like Role Scoper.

      • Anand on May 22, 2013 at 9:06 pm

        Is there another way without plugin

  9. Ben Lacey on February 7, 2012 at 5:38 am

    Nice collection of functions here. I might use these for future WordPress sites 🙂

  10. Thomas on February 14, 2012 at 6:34 am

    Hi and thanks for this – works great!

    Any idea why

    remove_submenu_page( ‘edit.php’, ‘post-new.php?post_type=listing’ );

    doesn’t remove “add new” from my custom post type menu “listing”?

    Cheers,
    Thomas.

    • Thomas on February 14, 2012 at 6:52 am

      got it: it has to be

      remove_submenu_page( ‘edit.php?post_type=listing’, ‘post-new.php?post_type=listing’ );

  11. David on February 14, 2012 at 8:28 am

    Very strange i cant seem to remove the users menu .. any idea?

  12. […] the WordPress admin panel for your client. Today’s link will go further on one point : customizing the WordPress admin menu. This complet and detailed guide will give you a few exemples and a big list of the WordPress admin […]

  13. Mozart on April 3, 2012 at 3:07 pm

    Thanks, man! Very useful!

  14. Sam on April 3, 2012 at 3:45 pm

    I would like to remove themes.php ? I can remove the sub-menu, but it can still be accessed via clicking ‘appearance’ menu.

  15. Jonsey on April 30, 2012 at 9:43 am

    Does anyone know a plugin that would do that? I assume you have to repeat this after each upgrade

    • Seth Stevenson on April 30, 2012 at 10:05 am

      Jonsey give Adminize a shot – http://wordpress.org/extend/plugins/adminimize/

    • Halley Son on October 13, 2012 at 1:33 am

      Hi Jonsey, I had the same question as you, and I found this plugin: Hide Admin Menu. It works like a charm, and I just need to check checkboxes :). I also can hide items in admin bar. Give it a look, it’s worth to try.

  16. Selectiveform on April 30, 2012 at 11:03 pm

    Does anyone knows how to use these with an array without having to retype the same lines over an over?
    I tried using the following:

    remove_menu_page (array(‘tools.php’,’upload.php’,’themes.php’));

    without success.

  17. […] Taken from: https://sethstevenson.net/customize-the-wordpress-admin-menu-based-on-user-roles/ […]

  18. podiatry898 on August 7, 2012 at 11:43 pm

    any individual have any info?

  19. gaston on November 30, 2012 at 6:23 am

    hi, i want to remove the sub-item poll-options from poll plugin… any idea?

    • Seth Stevenson on November 30, 2012 at 8:29 am

      Which poll plugin are you using?

      • John on January 14, 2013 at 8:05 am

        I think he is using WP-Polls. I have the same query. How can I get rid of some of the submenus? The link is /wp-admin/admin.php?page=wp-polls/polls-options.php. I’ve tried remove_submenu_page(‘wp-polls’, ‘polls-options.php’); and remove_submenu_page(‘admin.php?page=wp-polls’, ‘polls-options.php’); but neither worked.

  20. chandan on December 22, 2012 at 1:43 am

    Why does a slider show up at the bottom of the page ‘https://sethstevenson.net/customize-the-wordpress-admin-menu-based-on-user-roles/’ in firefox 17.0.1?

  21. Jervis Thompson on January 3, 2013 at 11:39 am

    You sir.. Are Awesome! Thanks for the detailed tutorial.

  22. steve on January 16, 2013 at 6:17 am

    Thanks for a great post on this topic, I have two questions:

    1 – How can I remove these pages and sub_pages appearing on the menu_bar (the links I can see on the front end of the site)? They still appear here even though they removed in the backend.

    2 – How can I remove the Header and Background sub_pages from Appearance?

    I’m hoping an answer to these two questions will be helpful to others also.

    • Paal Joachim Romdahl on June 22, 2015 at 6:17 am

      Hey Steve

      Did you figure this one out? I am also having difficulty removing Header and Background from the Appearance submenu.

  23. Joseph on January 31, 2013 at 10:23 pm

    Thank you for this contribution.

  24. Manuel on February 10, 2013 at 11:39 am

    Very very useful. Thanks a lot Seth.

  25. Fahad on May 7, 2013 at 1:58 am

    Thanks for the great contribution.The one i was looking for.

  26. kalpesh on May 24, 2013 at 9:07 am

    thank you very much

  27. Roshan on May 29, 2013 at 3:25 am

    Hi, Seth, great script, i have request, can u provide the code to hide the “publish” button for user roles, ex. hide it for editors, so they can only save as draft.

  28. juan on June 13, 2013 at 9:45 am

    Hey it was really helpfull.
    Thanks so much.

  29. Martin on December 23, 2013 at 11:11 am

    Hi, sadly didn’t work for me. WordPress 3.7.1 I tried to hide Menu “Your Profile” for everyone accept Admin, but didn’t work out. Any ideas why?

    function my_remove_menu_pages() {
    if(!current_user_can(‘activate_plugins’)) {
    remove_submenu_page( ‘users.php’, ‘profile.php’ );

  30. Menu’s aanpassen door klant – redacteur on June 2, 2014 at 9:35 am

    […] Eerst geef je de editor toegang tot ‘weergave’. En vervolgens geef je editors GEEN toegang tot themes en widgets. Met dank aan: https://sethstevenson.net/customize-the-wordpress-admin-menu-based-on-user-roles/ […]

  31. jasa website sekolah on June 21, 2014 at 12:28 am

    Thanks, very useful.
    I am only question, any wordpress plugin for get this customization?

  32. Cvall on November 27, 2014 at 2:10 pm

    Grande!!, muy completo la información se agradece.

    • Wordpress Jasa SEO on August 3, 2015 at 9:46 pm

      Wow I didnt know wordpress had this. Thanks for revealing this.

  33. Pelangsing Alami Detox on August 3, 2015 at 9:49 pm

    Great! Thanks for sharing the information. That is very helpful for increasing my knowledge in this field.

  34. Jual Token Listrik online on August 11, 2015 at 11:27 am

    Thanks, man! Very useful!

  35. Beli pulsa online on August 11, 2015 at 11:27 am

    Thanks your sharing

    • Sb1m on August 29, 2015 at 7:38 pm

      Cool stuff man.. Thanks alot

  36. John Miles on August 18, 2015 at 5:11 pm

    Thank you for this tutorial/help thingy. I created what I think should work but then received:
    “The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.”
    Any hints where to look for issues of this nature?

    John

  37. Jasa SEO Murah on September 6, 2015 at 2:32 pm

    Hello! I just would like to give a huge thumbs up for the wonderful information you’ve here on this post. I might be coming back to your blog for alot more soon.

  38. Pulsa on October 12, 2015 at 8:51 pm

    I just read the regularly one particular subject material. Beautiful articles or reviews, thank you to suit downloading and sharing an article content with all of us.

  39. jasa seo on October 20, 2015 at 12:28 pm

    Thank you for this tutorial/help thingy. I created what I think should work but then received:
    “The plugin generated 1 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.”

  40. jasa seo on October 20, 2015 at 12:29 pm

    Thank you for this tutorial/help thingy. I created what I think should work but then received:

  41. obat asam urat on December 7, 2015 at 9:52 pm

    thanks for sharing. i like it.

  42. prediksi togel hari ini on January 16, 2017 at 11:47 pm

    I like the helpful information you provide in your

  43. casino on January 17, 2017 at 1:03 am

    Nice Info Thx 😀

  44. Jual Alat Fitness on January 25, 2017 at 6:54 am

    Im thankful for the blog post.Much thanks again. Great.

  45. Togel Sidney on April 7, 2017 at 1:27 am

    Thank you so much

  46. Bokep Online on August 28, 2017 at 3:40 am

    Thank sir for you info ..

  47. Agen Bola Resmi on August 30, 2017 at 2:06 am

    After checking out a handful of the blog articles on your web
    site, I honestly like your way of blogging. I bookmarked it to
    my bookmark webpage list and will be checking back soon. Take a look at my web site as well and
    let me know your opinion.

  48. GoldenLeaf88 on September 3, 2017 at 3:38 am

    Goldenleaf88 situs layanan game online seperti sportsbook, casino online, slot games, poker online terpercaya Indonesia. visit agen judi bola dan casino

Leave a Comment