Advertisement
Guest User

Untitled

a guest
Aug 13th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. function members_hide_member_posts($query) {
  2.  
  3.     if( !$query->is_main_query() )
  4.         return;
  5.  
  6.     global $current_user;
  7.     if(empty($current_user->ID) || ($current_user->roles[0] != 'member' && $current_user->roles[0] != 'administrator') && (false === $query->query_vars['suppress_filters'])) {
  8.         $protected_posts = members_get_member_posts();
  9.         if( !empty( $protected_posts ) )
  10.             $query->set('post__not_in', $protected_posts);
  11.     }
  12. }
  13. add_action('pre_get_posts', 'members_hide_member_posts');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement