32 Responses

  1. Suraj
    Suraj June 18, 2013 at 15:47 | | Reply

    Thanks.

  2. Siddhartha Sinha
    Siddhartha Sinha June 18, 2013 at 18:08 | | Reply

    Hi Jean,
    I would like to say the way you illustrated will definetly going to help lots of blogger in terms of how to remove the menu items. Nice Coding.

    View my recent post on http://niceblogging.com/interview-of-successful-blogger-angela-mccall/

    Regards
    Siddhartha Sinha

  3. Paal Joachim Romdahl
    Paal Joachim Romdahl June 21, 2013 at 16:04 | | Reply

    Thanks for the article. Here is another plugin: http://www.kathyisawesome.com/449/nav-menu-roles/

  4. Birgit
    Birgit September 16, 2013 at 19:13 | | Reply

    very useful, thank you!

    Any idea how I could hide other users images/media from a user? The code above only seems to work for posts…

  5. oudin
    oudin November 26, 2013 at 16:50 | | Reply

    How can I remove menu items which other plugin add?

  6. Diego
    Diego January 13, 2014 at 14:54 | | Reply

    Thank you, man.

  7. 123reviewer321
    123reviewer321 March 28, 2014 at 12:52 | | Reply

    How do you remove plugin links like this:
    http://www.mydomain.com/wp-admin/admin.php?page=wpfilebase_sets

    I have tried “remove_menu_page( ‘admin.php?page=wpfilebase_sets’ );” but that didn’t do anything

    1. mparryy
      mparryy April 3, 2014 at 06:34 | | Reply

      I have this same problem.

    2. deb
      deb November 1, 2015 at 20:41 | | Reply

      Hi just put
      remove_menu_page( ‘wpfilebase_sets’ );

      Its done 🙂

      1. Yo! Web
        Yo! Web December 2, 2015 at 04:20 | | Reply

        Thanks deb, your comment helped me

      2. Simerjit
        Simerjit July 25, 2016 at 22:55 | | Reply

        didn’t work for me.. remove_menu_page is not working in my case… Will you please help me out..

  8. ssss
    ssss April 6, 2014 at 14:56 | | Reply

    Great another thread that not helping, i want to remove tools from admin menu…not using functions but just delete it….

  9. jokiruizlite
    jokiruizlite May 16, 2014 at 14:06 | | Reply

    Nice one! I’m using easy-admin-menu plugin, http://wordpress.org/plugins/easy-admin-menu/ Allows you to reorder and hide items in the menu with a very easy interface, just drag and drop. Might be useful

    1. Benoit Besnard
      Benoit Besnard September 5, 2016 at 05:04 | | Reply

      That’s also a interesting plugin although it can not bet set depending on user roles…

  10. alan
    alan May 24, 2014 at 16:22 | | Reply

    ? does not work

    1. alan
      alan May 24, 2014 at 16:25 | | Reply

      it does work… copying and pasting did not as I missed the top line… it works

      1. alan
        alan May 24, 2014 at 16:39 | | Reply

        very cool…. any idea how to force the particularly stubborn plugins that refuse to vanish to disappear? Maybe some way to “hide” them? That’s what the menu plugins have to do for these particular items. Thanks

  11. alan
    alan May 24, 2014 at 17:06 | | Reply

    the solution is to just put the very last bit of the url so instead of remove_menu_page( ‘edit.php?post_type=thirstylink’ ); you would put remove_menu_page( ‘thirstylink’ ); – hope that helps someone

  12. aanduque
    aanduque January 26, 2015 at 15:01 | | Reply

    I use this plugin that solves exactly this problem, but with a much nicer UI.

  13. kishor
    kishor October 27, 2015 at 22:57 | | Reply

    Nice one man… so helpful.. thanks

  14. Janos
    Janos May 18, 2016 at 01:23 | | Reply

    Many thanks for sharing this, very useful.

    I still have a problem with removing an item from the dashboard top menu line, which seems to fall exactly into the group of pages what I can remove from the sidebar:
    …wp-admin/admin.php?page=wpseo_dashboard
    I can’t figure out why it refuses to disappear.
    I’d appreciate an advice

  15. Chris
    Chris June 28, 2016 at 13:37 | | Reply

    Hello! What a great bit of code, especially useful for us was hiding posts from other authors in the list.

    How about multiple authors of a post, all being able to see that post in their respective lists?

    add_action( ‘load-edit.php’, ‘posts_for_current_contributor’ );
    function posts_for_current_contributor() {
    global $user_ID;

    if ( current_user_can( ‘contributor’ ) ) {
    if ( ! isset( $_GET[‘author’] ) ) {
    wp_redirect( add_query_arg( ‘author’, $user_ID ) );
    exit;
    }
    }

    }

    With the original code, even after adding an author to a post (now post has two authors) the post does not show up in the second, additional authors, post list.

    Only the first and original author of a post is able to see the post (which now has multiple authors.)

    Using the Co-Authors Plus plugin to add multiple authors to a post. https://wordpress.org/plugins/co-authors-plus/

    In this article, it talks about how Co-Authors plugin stores the terms… but I’m not sure how one would extract those terms and use them with the wp_redirect, to list more than one author. http://wordpress.stackexchange.com/questions/5871/how-to-display-an-archive-with-multiple-authors

    Hope that makes sense : ) thank you for any advice.

  16. ben
    ben July 16, 2016 at 19:56 | | Reply

    Thanks your code does work! But when I add condition
    if ( current_user_can( ‘wpmayorauthor’ ) ) {…}

    to my child theme not to the main theme it does not work. I think it does not recognize the current_user_can function. /themename-child/function.php any ideas why? Do I need to somehow do an include so the current_user_can function is recognized?

    Thanks

  17. Laura
    Laura August 17, 2016 at 13:34 | | Reply

    How would one adapt this for frontend menu items?

    1. mark.zahra
      mark.zahra September 5, 2016 at 06:22 | | Reply

      Hi Laura, in what way? This is about the WP Admin menu. For the menu on your frontend you can just use the WP Menu settings…

  18. sagar
    sagar October 13, 2016 at 03:18 | | Reply

    Hello jean, How I can remove menu item that have url: wp-admin/admin.php?page=wpfront-user-role-editor.

  19. Jay
    Jay October 18, 2016 at 15:53 | | Reply

    This code didn’t work for me with WP 4.5.4
    I have a custom user role that I created earlier so I have…

    add_action( ‘admin_init’, ‘remove_menu_pages’ );
    function remove_menu_pages() {

    global $user_ID;
    if( current_user_can(‘client’) ) {
    remove_menu_page(‘plugins.php’);
    }
    }

    …but the plugin menu item continues to show. Would really like to figure out what’s wrong here.

  20. Francisco
    Francisco November 8, 2016 at 14:12 | | Reply

    Hi! can anyone tell me which file should I edit? I can’t try it out since I don’t know which PHP should I mess with. Thanks!

    1. Eoin H
      Eoin H November 29, 2016 at 03:02 | | Reply

      Francisco, usually for this kind of thing, you would do it in the themes’ functions.php file. If your theme doesn’t have that file, simply create it withing the theme folder.

  21. Annapurna Agrawal
    Annapurna Agrawal December 23, 2016 at 00:31 | | Reply

    Hi,
    I am unable to remove the menu pages created by the acf plugin. I am using the code remove_menu_page( ‘edit.php?post_type=acf’ ).
    Can you please help me out.

    1. Eoin H
      Eoin H December 23, 2016 at 07:04 | | Reply

      Try using code remove_menu_page( ‘acf’ )

Leave a Reply

  
Please enter an e-mail address