• Resolved colouro

    (@colouro)


    I want other users in custom post types named “xyz” to see only their posts. I did it with this function:

    add_filter('pre_get_posts', 'posts_for_current_author');
    
    function posts_for_current_author($query) {
    
    	if(!current_user_can('administrator')) {
    	global $user_ID;
    		$query->set('author',  $user_ID);
    	}
    	return $query;
    }

    But the problem is that they dont see custom fields. How can that be?
    Maybe someone has the same issue?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Why when I set query author to current user id disappears meta boxes?’ is closed to new replies.