Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function members_hide_member_posts($query) {
- if( !$query->is_main_query() )
- return;
- global $current_user;
- if(empty($current_user->ID) || ($current_user->roles[0] != 'member' && $current_user->roles[0] != 'administrator') && (false === $query->query_vars['suppress_filters'])) {
- $protected_posts = members_get_member_posts();
- if( !empty( $protected_posts ) )
- $query->set('post__not_in', $protected_posts);
- }
- }
- add_action('pre_get_posts', 'members_hide_member_posts');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement