• Plugin works great on my computer when I sign in as her I can only see files uploaded as that user, but when I log into the site as her, from her computer, she can see all the files uploaded not just hers. We cleared some of the history, but still no luck. Any thoughts? Thanks

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter bdvirtue

    (@bdvirtue)

    Now that I logged back in as her on my computer I stand corrected… I can see all files not just the ones she uploaded. ??

    Thread Starter bdvirtue

    (@bdvirtue)

    Sorry for all of the replies by me…
    I did figure something out. When media is in the icon view it is fine, it is when it is in list view that she can see every file uploaded to the site. Is there something I can do to correct this? Thanks again.

    This plugin uses a single function:

    add_filter( 'ajax_query_attachments_args', 'mrfx_show_current_user_attachments' );
    
    function mrfx_show_current_user_attachments( $query ) {
        $user_id = get_current_user_id();
        if ( $user_id && !current_user_can('administrator') && !current_user_can('editor') ) {
            $query['author'] = $user_id;
        }
        return $query;
    }
    

    This filter works great for the grid mode, but not for the list mode. You will need the following for the list mode:

    add_filter( 'request', 'mrfx_show_current_user_attachments_list' );
    function mrfx_show_current_user_attachments_list( $query ) {
    
    	$screen = get_current_screen();
    
    	if ( in_array( $screen->id, array( 'upload' ) ) ) {
    		$user_id = get_current_user_id();
    		if ( $user_id && !current_user_can('administrator') && !current_user_can('editor') ) {
    			$query['author'] = $user_id;
    		}
    	}
    	return $query;
    }

    I got the idea from Woothemes Sensei. They have the same functionality, but for their own Teacher role.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Author View’ is closed to new replies.