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 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.

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

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

Your Answer


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

Browse other questions tagged or ask your own question.