39 Responses

  1. Chad Holden
    Chad Holden June 13, 2011 at 2:11 pm |

    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 June 13, 2011 at 2:34 pm |

    I can see where this would come in handy.

    Reply
  3. Kel
    Kel June 13, 2011 at 6:35 pm |

    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 June 13, 2011 at 8:51 pm |

    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 June 14, 2011 at 11:23 am |

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

    Reply
  6. Nicholas
    Nicholas June 20, 2011 at 9:37 am |

    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 June 22, 2011 at 9:03 am |

    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 June 22, 2011 at 11:11 am |

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

      Reply
  8. Jimmy
    Jimmy June 24, 2011 at 2:54 am |

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

    Reply
  9. Abdullah
    Abdullah June 24, 2011 at 7:04 am |

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

    Reply
  10. Jeremy Davis
    Jeremy Davis June 28, 2011 at 11:00 am |

    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 July 16, 2011 at 5:27 pm |

    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 August 12, 2011 at 6:58 am |

    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 September 14, 2011 at 1:17 am |

    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 November 25, 2011 at 6:39 am |

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

    Reply
  18. elixoid
    elixoid December 5, 2011 at 6:55 am |

    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 January 25, 2012 at 4:09 pm |

      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 January 27, 2012 at 12:55 pm |

    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 February 13, 2012 at 5:32 pm |

    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 April 17, 2012 at 12:28 pm |

    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 May 29, 2012 at 3:36 am |

    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. 黄文镇
    黄文镇 September 6, 2012 at 3:24 am |

    not work in wp 3.0 ?

    Reply
  24. Ma
    Ma September 17, 2012 at 2:12 pm |

    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 September 26, 2012 at 6:16 am |

    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 November 8, 2012 at 4:45 am |

    Thank you..!!

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

    Reply
  27. g0g0l
    g0g0l November 29, 2012 at 4:07 am |

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

    Reply
  28. pako69
    pako69 January 15, 2013 at 4:18 am |

    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 January 24, 2013 at 10:27 am |

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

    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.