Support

Account

Home Forums Front-end Issues Hiding media library from users Reply To: Hiding media library from users

  • Howdy,

    I recently found this, which is working for me

    add_filter( 'posts_where', 'devplus_attachments_wpquery_where' );
    function devplus_attachments_wpquery_where( $where ){
    	global $current_user;
    
    	if( is_user_logged_in() ){
    		// we spreken over een ingelogde user
    		if( isset( $_POST['action'] ) ){
    			// library query
    			if( $_POST['action'] == 'query-attachments' ){
    				$where .= ' AND post_author='.$current_user->data->ID;
    			}
    		}
    	}
    
    	return $where;
    }

    Hope it helps!