Support

Account

Home Forums Add-ons Gallery Field Gallery field showing all media Reply To: Gallery field showing all media

  • You can use this code in your functions.php file

    // Restrict media library to show only own user files
    add_action('pre_get_posts','ml_restrict_media_library');
    function ml_restrict_media_library( $wp_query_obj ) {
    
    	global $current_user, $pagenow;
    
    	if( !is_a( $current_user, 'WP_User') )
    
    		return;
    
    	if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
    
    		return;
    
    	if( !current_user_can('delete_pages') )
    
    		$wp_query_obj->set('author', $current_user->ID );
    
    	return;
    
    }