WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently updated my WordPress site into the latest WordPress version, and i added a code to my functions.php that would add a capability to subscriber to upload using WordPress media upload. I successfully remove the media library tabs on the later version of WordPress but when I updated the version it seems like the code does not work anymore. Any ideas how to fix this?

This is the previous code which I googled before:

function remove_medialibrary_tab($tabs){
  if ( !current_user_can( 'administrator' ) || !current_user_can( 'editor' ) || !current_user_can( 'contibutor' ) || !current_user_can( 'author' ) ) {
    return $tabs;
  } else {
    return $tabs;

if ( !current_user_can('upload_files') ){
    add_action('init', 'allow_user_to_upload');

function allow_user_to_upload() {
    $subscriber = get_role('subscriber');
share|improve this question
up vote 5 down vote accepted

If you want to hide the Media Library submenu:

Media Library submenu

you can do it via the admin_menu action:

function wpse85351_hide_submenus() {
           global $submenu;
           unset($submenu['upload.php'][5]); // hide the Media Library
add_action('admin_menu', 'wpse85351_hide_submenus');

If you want to change/remove the Media strings:

Media strings

you can use the media_view_strings filter:

function wpse85351_media_strings($strings) {
    // only for subscribers:
        // remove "mediaLibraryTitle"
    return $strings;

You can use


instead of

!current_user_can( 'administrator' ) || !current_user_can( 'editor' ) || !current_user_can( 'contibutor' ) || !current_user_can( 'author' )

to restrict it only to "subscribers".

Here is the array of all the Media View Strings that you can unset or change to your needs:

    [url] => URL
    [addMedia] => Add Media
    [search] => Search
    [select] => Select
    [cancel] => Cancel
    [selected] => %d selected
    [dragInfo] => Drag and drop to reorder images.
    [uploadFilesTitle] => Upload Files
    [uploadImagesTitle] => Upload Images
    [mediaLibraryTitle] => Media Library
    [insertMediaTitle] => Insert Media
    [createNewGallery] => Create a new gallery
    [returnToLibrary] => ← Return to library
    [allMediaItems] => All media items
    [noItemsFound] => No items found.
    [insertIntoPost] => Insert into post
    [uploadedToThisPost] => Uploaded to this post
    [warnDelete] => You are about to permanently delete this item.
  'Cancel' to stop, 'OK' to delete.
    [insertFromUrlTitle] => Insert from URL
    [setFeaturedImageTitle] => Set Featured Image
    [setFeaturedImage] => Set featured image
    [createGalleryTitle] => Create Gallery
    [editGalleryTitle] => Edit Gallery
    [cancelGalleryTitle] => ← Cancel Gallery
    [insertGallery] => Insert gallery
    [updateGallery] => Update gallery
    [addToGallery] => Add to gallery
    [addToGalleryTitle] => Add to Gallery
    [reverseOrder] => Reverse order
share|improve this answer
thank you so much @birgire .. this save my day.. God bless. – Raymond Serion Feb 12 '13 at 5:42
Can I ask for more help? How can I give access to all kind of users(even non logged in) to add media button in the front end? – Rohit Pande Apr 17 '13 at 6:45
This is great, thanks birgire – henrywright Dec 28 '13 at 22:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.