• hi all, i used the code below to enable the function :

    function hide_posts_media_by_other($query) {
    	global $pagenow;
    
    	if( ( 'edit.php' != $pagenow && 'upload.php' != $pagenow   ) || !$query->is_admin ){
    		return $query;
    	}
    
    	if( !current_user_can( 'manage_options' ) ) {
    		global $user_ID;
    		$query->set('author', $user_ID );
    	}
    	return $query;
    }
    add_filter('pre_get_posts', 'hide_posts_media_by_other');
    
    add_filter( 'posts_where', 'hide_attachments_wpquery_where' );
    function hide_attachments_wpquery_where( $where ){
    	global $current_user;
    	if( !current_user_can( 'manage_options' ) ) {
    		if( is_user_logged_in() ){
    			if( isset( $_POST['action'] ) ){
    				// library query
    				if( $_POST['action'] == 'query-attachments' ){
    					$where .= ' AND post_author='.$current_user->data->ID;
    				}
    			}
    		}
    	}
    
    	return $where;
    }

    Hi, it’s possible to change for enable it on some post types only?

    For example: i need logged users to view other’s pages only, instead of articles.

    Thanks in advance!

The topic ‘Hide WordPress Posts and Media uploaded by other users’ is closed to new replies.