Advertisement
geminilabs

[site-reviews] Exclude logged-in user's reviews

Dec 28th, 2022
1,506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. /**
  2.  * This snippet will exclude the logged-in user's reviews from the latest reviews.
  3.  * To make it work, add a "other-reviews" class to the Latest Reviews block or shortcode.
  4.  *
  5.  * @param array $values
  6.  * @param string $method
  7.  * @param array $args
  8.  * @return array
  9.  */
  10. add_filter('site-reviews/defaults/reviews', function ($values, $method, $args) {
  11.     if (is_user_logged_in() && 'other-reviews' === glsr_get($args, 'class')) {
  12.         $values['user__not_in'] = [get_current_user_id()];
  13.     }
  14.     return $values;
  15. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement