I've found a way to hide posts by matching the current user meta key value with a list of an authors pre-approved meta values for a specific user field. First_name for example.
The code redirects any current user who doesn't match the authors list of meta values. This works well.
What I'd like to do is give the ability for authors to make some of their posts accessible to all by a selecting either a 'public' category or a 'private' category.
Currently the current user can't see any posts from an author they don't match meta values with. With this fix, they would be able to see any posts that aren't in the category 'private'. BTW, all posts are viewable by login only.
This is the part of my code that restricts the access to posts. I've added in post_category. I've tried the category name, the category ID and an array as below, even though I only want to create a match with one category.
How can I include a specific category in the restriction?
$myposts = get_posts(array( 'p' => $pid, 'posts_per_page' => -1, 'post_type' => 'post', 'post_category' => array('4'), 'post_status' => 'publish', 'author' => $value, ));