1

I'm in the process of adding a front-end post editor to one of my sites. In doing so, I need to prevent certain users from being able to upload media. I have things "kind of" working but there are a few problems.

  1. Though the title for the Upload Media tab is hidden, the tab itself still displays and allows users to "drag and drop" for media upload. I want this entire tab content gone.
  2. I've unset the Media Library Title, but it still shows up.

Here is the current code I'm using...

// Remove items from Media Uploader if current user has a Member role
function member_media_view_strings( $strings ) {
    $author_data = get_userdata( get_current_user_id() );
    $author_role = implode(', ', $author_data->roles);
    if ( $author_role == 'member' ) {
        unset( $string['uploadImagesTitle'] );
        unset( $strings['uploadFilesTitle'] );
        unset( $strings['createGalleryTitle'] );
    }

    return $strings;

}

add_filter( 'media_view_strings', 'member_media_view_strings', 99 );


// Remove items from Media Uploader if current user has a Member role
function member_media_view_tabs($tabs) {
    $author_data = get_userdata( get_current_user_id() );
    $author_role = implode(', ', $author_data->roles);
    if ( $author_role == 'member' ) {
        unset($tabs['gallery']);
        unset($tabs['type']);
    }

    return $tabs;

}

add_filter( 'media_upload_tabs', 'member_media_view_tabs', 99 );

Any help is appreciated. Thanks!

-EDIT-

I've attached a screenshot of what the media uploader looks like now....it's weird.

screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.