WordPress.org

Ready to get started?Download WordPress

Forums

New Media Uploader, restrict writer to view own media (7 posts)

  1. jasjoerii
    Member
    Posted 1 year ago #

    Hello,

    I used to have a code in my functions.php for restricting writers to view only their own media, but that code doesn't work since I upgraded wordpress to 3.5 because of the New Media Uploader.

    I am using a adjusted version (by myself) of WP User Frontend. Writers can write posts from frontend (using the wp_editor function). Can you help me out?

    Extra question: I'd also like writers not to be able to make a gallery and featured image. It really has to be simple (so actually only uploading and inserting image). Can you help me out on that too?

  2. jesse.t
    Member
    Posted 1 year ago #

    I'm looking to do something similar, you could piece together a few items

    <snippet from here: http://wordpress.stackexchange.com/questions/76771/how-can-i-hide-media-library-images-from-general-users&gt;

    function remove_medialibrary_tab($tabs) {
        if ( !current_user_can( 'update_core' ) ) {
            unset($tabs['library']);
            return $tabs;
        }    }
    add_filter('media_upload_tabs','remove_medialibrary_tab');

    $tabs['library'] contains all the information for displaying the tab. So instead of unsetting it, maybe you can get it to print out, and modify it with a new query to only receive items uploaded by the current user:
    <snippet from here: http://wordpress.stackexchange.com/questions/38634/get-attachments-by-user&gt;

    $user_id = 1;
    $the_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inheret', 'author' => $user_id) );
    if ( $the_query->have_posts() ) while ( $the_query->have_posts() ) : $the_query->the_post();
       the_title();
    endwhile;
  3. jesse.t
    Member
    Posted 1 year ago #

  4. jasjoerii
    Member
    Posted 1 year ago #

    Problem is, that it doesn't work with the new Media Uploader (since 3.5). I had a similar code for the previous uploader, but it doesn't work for this one.

  5. jasjoerii
    Member
    Posted 1 year ago #

    And I'm working from the front-end. So the changes have to be in the pop-up of the Media Uploader. Not in de backend (wp-admin)

  6. jesse.t
    Member
    Posted 1 year ago #

    Ah well you are still able to call the thickbox if you need this fix for a live server.

  7. Yaron Guez
    Member
    Posted 1 year ago #

    I'm having the same problem. Have you made any progress on this jasjoerii?

Topic Closed

This topic has been closed to new replies.

About this Topic