How to remove the Media Library tab in the WordPress media uploader

2010-10-08 12:09pm by Ann

By default, WordPress allows a user with the “upload_files” capability to view all items in the media library. Here’s how to remove the Media Library tab in the WordPress media uploader completely (e.g. for contributors without the “edit_others_posts” capability).

Copy and paste the following code into a plugin or the theme functions.php file:

function remove_medialibrary_tab($tabs) {
  return $tabs;

29 Responses to “How to remove the Media Library tab in the WordPress media uploader”

  1. Tim says:

    Brilliant; thanks!

  2. John says:

    Excellent, been looking for this for a while!

  3. Danny says:

    Ann, this is probably the second or third times I have ever leave a comment on people’s blog..

    Thank you so much!!

  4. Brad says:

    I’m sorry but I’m just learning.

    Where do I put this exactly??

    In my theme folder (wp-content/themes/autofocuspro) there is a functions.php file do I put it in there? Where exactly in that file?

  5. Brittany says:

    This rocks, Thank you! so much for this, so quick and simple.

  6. tibo says:

    Where I do put exactly, it doesn’t work when I tryed it ?


  7. J says:

    Excellent! Thanks.

    WordPress does a lot of dumb stuff by default. This helps a lot.

  8. Keith J. Barry says:

    Arigatou, Superann-san.
    Trying to do something similar, but it’s beyond my skills at this point. I’d like to have Authors see only the From URL tab, and have From Computer and From Media Lib tabs disabled/invis.
    Would you be able to help me out with this?
    Thank you,

  9. Keith J. Barry says:

    Oh yeah! Figuring out what the other tabs were called was the key to adapting your excellent code. Got it! Many thanks for posting this, Superann.

  10. The Frosty says:

    Thanks for this quick snippet!

  11. Ajay says:

    Thank you. Thank you. Thank you.

  12. Cliff says:

    Hi Ann,
    I didn’t manage to hide my media library.

    But I tried, after the WP update to 3.3.
    Which I believe is why I can’t fix this.

    Also in WP 3.3, I would like to remove (for all users) the WP logo (and dropdown) which is in the left side of admin bar.

    Can you kindly suggest how?

    Thanks a lot

    • Ann says:

      You should still be able to unset the library tab the same way in 3.3. Are you checking it as a user without the “edit_others_posts” capability? You can just get rid of that check if you want it gone for all users.

      As for the admin bar wp logo, you can do this to get rid of it:

      function admin_bar_render() {
        global $wp_admin_bar;
      add_action('wp_before_admin_bar_render', 'admin_bar_render');

  13. cliff says:

    hello ann,
    but i just fixed it with a plug (Adminimize)


  14. CG says:

    Hi Ann,

    Thanks for this fix …. Is there a way to have this apply to user roles instead of capabilities? Using the current method tabs are also hidden for admin since that role has the capability edit_others_posts.

    Any help is appreciated.


  15. yoolee says:

    Hi Ann,

    Same goes for me as for CG, (since I can only work with logic because my programming or html skills are non-existent) I would need something the other way around, where a lower lever user role eg. author cannot see the media library and admin users still can. If I assign this script to a capability than admin users will obviously have everything aother users have so I hide the library from everyone. Any suggestion is greatly appreciate! Thanks in advance.

  16. yoolee says:

    I just found this in a WP forum, maybe this is it:

    //Remove Media Library Tab
    function remove_medialibrary_tab($tabs) {
    if ( !current_user_can( ‘administrator’ ) ) {
    return $tabs;
    return $tabs;

    • Ann says:

      “administrator” is not a built-in capability, so this wouldn’t work unless you have explicitly defined that capability and assigned it to the administrator role.

  17. Ann says:

    If you want to limit this to admins, you can check for a different capability that only an admin would have like “update_core”.

    Check the codex for a list of the default built-in capabilities and the roles they are associated with:

  18. Chris says:

    Hey, thanks for the tip! It works! 🙂

  19. Rajkumar says:

    A simple Edit and a Great Utility !

    Thank You .

  20. Jim says:

    I’m trying to append your code in a child twentyten theme. It works fine in the parent – but I’m missing something in the child theme setup as it give no result for me there. Are you able to provide any guidance on that. I’m using your code as below.

    function remove_medialibrary_tab($tabs) {
    return $tabs;

    (I’ve reviewed the basic wordpress docs on function.php in a child theme – understanding that this is not like style.css and not fluent enough to know how to execute as a plugable command.)

    Any help or guidance would be appreciated. thank you.

    • Jim says:

      Just to close out my earlier question – resolved it with the creation / insertion of the code into a mini-plugin and have hiddne / unseatted the media gallery link / tab. Thank you very much for the great code to set me down this path. : )

  21. Alonso says:

    Hi, I have the following source code and does not work well

    function remove_medialibrary_tab($tabs) {
    return $tabs;

    What could be my mistake?

  22. pawlo says:

    Great work a lot of thanks !

  23. Sam O says:

    I have an issue at present where we have a WP site with multi-user capabilities, using User Role Editor plug-in, in which I need all user access levels to be able to access and utilise the media library. It seems to work fine for a while, but then for lower user access levels the media library keeps going completely blank – not giving access to the libraries entries to lower access levels. Any ideas?

    This has happened a couple of times, and now we’re thinking of trying to completely remove the media library and replace this functionality with something else. Does anyone have any ideas a) how to completely remove the media library from all user access levels and b) what the best replacement would be. If we need to hack it, cest la vie!

    Any help, very gratefully received!

Leave a Reply