44 Responses

  1. Chad Holden
    Chad Holden Published |

    This is EXACTLY what I needed for what I am working on literally this second for a client. Much appreciated for the timeliness!

    Reply
  2. The Frosty
    The Frosty Published |

    I can see where this would come in handy.

    Reply
  3. Kel
    Kel Published |

    How about the menu items generated from plugins such as Contact Form 7 which use slug/urls such as: admin.php?page=wpcf7 or even, options-general.php?page=contact-form-captcha/contact-form-captcha.php

    Reply
  4. Mark Wiard
    Mark Wiard Published |

    I love the capability, it seems like a nice way to keep clients out of trouble. I see one small issue. On the actual example for removing a “sub-menu page”, you have

    remove_menu_page ( ‘themes.php’, ‘theme-editor.php’ );

    it should be

    remove_submenu_page ( ‘themes.php’, ‘theme-editor.php’ );

    Thank you for great instructive posts.

    Reply
  5. Eric Marden
    Eric Marden Published |

    This is much nicer than the old method of filtering the menu array. Thanks for posting this.

    Reply
  6. Nicholas
    Nicholas Published |

    This is very useful for cleaning up the admin area. To take it a little further, how can we check for user level before removing menu items? For example, to remove dashboard for subscribers.

    Reply
  7. Jason
    Jason Published |

    Thanks Justin for the post.

    Works fine locally.

    Am having a problem getting this to work on live server, seeing Internal Server Error 500 whenever I try to access Admin screens. Not sure what this could be caused by. I’ve stripped everything else out of functions.php, and checked it’s not a typo. I’ve copied your above code as is:

    add_action( ‘admin_menu’, ‘devpress_remove_menus’, 999 );

    function devpress_remove_menus() {

    remove_menu_page( ‘link-manager.php’ );

    }

    If I comment out remove_menu_page the Admin screens work.

    Would be very grateful for any ideas. Thanks.

    Reply
    1. Jason
      Jason Published |

      Sorted – of course it would help if it was latest version – doh.

      Reply
  8. Jimmy
    Jimmy Published |

    what about the tags menu ?
    the slug is the same for tags and categories menu.

    Reply
    1. Tim
      Tim Published |

      Just figured out how to remove the tags or categories submenu items. It would be like this:

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

      Hope that helps…

      Reply
  9. Abdullah
    Abdullah Published |

    Waon very awesome trick, easily implement in less time :) Thankx

    Reply
  10. Jeremy Davis
    Jeremy Davis Published |

    Good to know. The WordPress sidebar nav has really gotten out of hand for me with 7 custom post types, plus a dozen plugins that all want their place in the sidebar. Any pixels I can get back is worth it.

    Reply
  11. Remove Menu Item in WordPress Admin Panel - WordPress, Alternatively, $GLOBALS, Remove, False, Discussion - WP Engineer
  12. Removing menu pages from the WordPress admin
  13. Tim O'Pry
    Tim O'Pry Published |

    Can you advise how to remove a sub-menu from the admin bar at the top? I am trying to remove two of the selections from the Add New menu utilizing

    function remove_admin_bar_links() {
    global $wp_admin_bar;
    $wp_admin_bar->remove_menu(‘new-post’);
    $wp_admin_bar->remove_menu(‘new-page’);
    }
    add_action( ‘wp_before_admin_bar_render’, ‘remove_admin_bar_links’ );

    But it does not seem to work for submenus. Top-level menus I can remove without problem.

    Reply
  14. Meyan Lellu
    Meyan Lellu Published |

    Is there any way to hide a certain page from the admin panel? For example this: /wp-admin/post.php?post=123

    Reply
  15. Remove Menu Item in WordPress Admin Panel | Free Wordpress Themes|Plugins|Buddypress Themes|Plugins|Wordpress 3.x|Wordpress MU|Wordpress MS|Wordpress 3.1.3 (latest version)
  16. Jason
    Jason Published |

    Great article. Thanks. This will come in handy with limiting what pages clients will see.

    Reply
  17. Katie @ Women's Magazine
    Katie @ Women's Magazine Published |

    Awesome, i would love to see how to add custom menus too.

    Reply
  18. elixoid
    elixoid Published |

    Menu items disabled this way are still accessible via direct typing in address bar. They’re not visible in admin left menu but if you type:

    http://yourdomain.com/wp-admin/theme-editor.php

    you can still get the editor.

    Is there any way to disable/hide theme/plugin editor from direct address access?

    Reply
    1. Billy
      Billy Published |

      I was wondering the same thing as @elixoid . Just removing the page from the menu is definitely nice, but it doesn’t prevent users from still accessing the page itself and mucking with options we would rather they not. I had toyed around with the “get_current_screen()” function, but it is difficult to determine the “base”, “id”, or “action” attribute values for various admin pages. For example, I tried the following to disable the “Add User” admin page for a networked site:

      # in functions.php file

          add_action('current_screen', 'disable_admin_menu_pages');
          function disable_admin_menu_pages()
          {
            $info = get_current_screen();
            if ($info->base == 'user' && $info->action == 'add' && !current_user_can('manage_network')){
              wp_redirect(admin_url()); exit;
            }
          }

      But this will become lengthy with many other pages, and takes an initial var_dump of “$info” on each page I want blocked so I can check what the values are. Is this the best way to go about this, or is there a better way?

      Reply
  19. JP
    JP Published |

    Thanks for posting this. Most articles are just a code dump with no explanation.

    Does anyone know how to MOVE submenu items? Or maybe an article link that shows how to do this? It drives me up the wall that every plugin handles this differently; some devs put their admin menus under Tools, some put it under Plugins, some set up their own menus (Contact Form 7, for example). I assume it would be some combination of ‘remove_submenu_page’ and ‘add_submenu_page’ but was looking for some pointers. Thx

    Reply
  20. Brett
    Brett Published |

    From this article, is it safe to replace:

    add_action( 'admin_menu', 'my_remove_menus', 999 );

    with:

    add_action( 'admin_init', 'my_remove_menus', 999 );

    ?

    I had a number of items (non-standard WP pages) not work with admin_menu, that I could suddenly hide with admin_init, like: remove_submenu_page( 'users.php', 'user-role-editor.php' );

    Reply
  21. Ralph
    Ralph Published |

    Hi,

    This works for most menu items but not all and i can’t work out why? It’s certain plugins and themes. for example I have a theme framework which give the an admin page at /admin.php?page=sitemile-framework

    I can’t for the life of me work out what the slug should be. This doesn’t work:

    remove_menu_page( 'sitemile-framework' );

    but I found the code that is creating the item and it is:

    add_menu_page(__('SiteMile'), __('SiteMile'), 8,'sitemile-framework', 'sitemile_framework_settings', $icn, '30' );

    So why is my code not working? Can anyone shed some light?

    Thanks for the post :)

    Reply
  22. Abdullah
    Abdullah Published |

    Wow, I search and use many codes for remove admin menus but not work your code snipt work like charm. :)

    Thanks for you help.

    Reply
  23. 黄文镇
    黄文镇 Published |

    not work in wp 3.0 ?

    Reply
  24. Ma
    Ma Published |

    What about other plugins instead of Contact Form 7?
    How can I find the slugs from top level menu and submenu of them?

    Thanks

    Reply
  25. Matt
    Matt Published |

    Thanks for the great post.

    I’ve come a bit unstuck though, wondered if you could help.

    I have a plugin with an admin page whose capability is set to “administrator”, I need to change this to something more useful.

    I can’t edit the plugin directly so I thought that by removing the submenu page in functions.php and then re-adding it with the appropriate capability type it would solve the problem.

    The menu item is now visible to the roles that I want but accessing the page still gives the “insufficient permissions” error.

    What am I missing?

    Reply
  26. Baraja Blog
    Baraja Blog Published |

    Thank you..!!

    Really nice post.. It’s Work..
    I’d like to improve my knowledge in wordpress

    Reply
  27. g0g0l
    g0g0l Published |

    What about removing the Pods Admin from the backend? Nothing works here :(

    Reply
  28. pako69
    pako69 Published |

    Hi and thanks, it really help me.

    What about to hide some non standard Wordpress submenu created by plugin like Background manager, or upPrev, the submenu links are :

    …./wp-admin/themes.php?page=xYzc4O
    or
    …/wp-admin/themes.php?page=upprev/admin/index.php

    thanks

    Reply
  29. Mike
    Mike Published |

    Thanks, you explained it very well. I assumed you would be able to just put the menu names into the function.

    Reply
  30. Mark
    Mark Published |

    999 was the answer!!!

    Thank you very much

    Reply
  31. Kaushik
    Kaushik Published |

    I would like to know how to check the menu exists or not in the right panel bar ?

    Because I want to create a single menu for all of my plugin, and when user installs the second plugin , the plugin should check

    if (menu_available) then add the plugin to submenu

    else {plugin should create a menu and then add that to the submenu}.

    Reply
  32. Efrain
    Efrain Published |

    Thanks for this tutorial.

    I’m using a multisite install and I can’t get this to work on my top admin bar. I’m trying to remove the same sub-menu items under all of my sites that are listed under the My-Sites parent menu item, but I don’t really know how to get the slugs for this to work. Any help will be appreciated. Thanks!

    By the way… you look like Shia LaBeouf in you Gravatar pic.

    Reply
  33. Jack
    Jack Published |

    Hi there,

    I can’t find a solution to this and I’m hoping someone can help.

    I need to remove the submenus of a theme I bought. My brother will be using the theme and I don’t want him playing around with updates etc without my consent. The URLs are as below:

    Parent Slug: admin.php?page=spyropress

    Menu Slug: admin.php?page=spyropress-update

    Thank you.

    Reply

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/Web site in attribution.

Please use your real name or a pseudonym (i.e., pen name, alias, nom de plume) when commenting. If you add your site name, company name, or something completely random, I'll likely change it to whatever I want.

css.php