Advertisement
Guest User

Untitled

a guest
Nov 17th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. add_filter( 'the_comments', 'my_the_comments', 10, 2 );
  2.  
  3. function my_the_comments( $results, &$comment_query ) {
  4.     global $current_user;
  5.  
  6.     if ( !is_admin() ) {
  7.         if ( isset( $current_user ) && ( $current_user instanceof WP_User ) ) {
  8.             if ( is_array( $results ) ) {
  9.                 foreach ( $results as $key=>$comment ) {
  10.                     $post_id = $comment->comment_post_ID;
  11.                     $user_id = $current_user->ID;
  12.                     if ( !Groups_Post_Access::user_can_read_post( $post_id, $user_id ) ) {
  13.                         unset( $results[$key] );
  14.                     }
  15.                
  16.                 }
  17.             }
  18.         }
  19.     }
  20.     return $results;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement