Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I just want to let user see only their own files in media library. I have 2 questions:

  1. it works great on list of media library.

    add_action('pre_get_posts','users_own_attachments');
     function users_own_attachments( $wp_query_obj ) {
    
     global $current_user, $pagenow;
    
    //echo 'pagenow='.$pagenow;
    
      if( !is_a( $current_user, 'WP_User') )
       return;
    
      if( 'upload.php' != $pagenow )
        return;
    
      if( !current_user_can('delete_pages') )
       $wp_query_obj->set('author', $current_user->id );
    
         return;
    }
    

But when you upload files with modal (lightbox) media libray, it shows all of files.

I have an avatar uploader in you profile page (/wp-admin/profile.php). when I click upload from media library. it popup a modal and shows all of files even not my own files.

How can I make it the popup modal to show only my files/ pictures?

  1. I have an avatar uploader on front-end too. I also need to make it show only own pictures on media modal.

How I could add the page? I did echo $pagenow; it's all index.php.

I believe that if my 1st question has a solution then it would be fine with front end as well.

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.