Advertisement
geminilabs

Customize permission for responding to reviews on the frontend

Nov 26th, 2024 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. add_filter('site-reviews-authors/can/respond', function (bool $canRespond, $review): bool {
  2.     $user = wp_get_current_user();
  3.     if (!in_array('company_role', (array) $user->roles)) {
  4.         return $canRespond; // user does not have the company role
  5.     }
  6.     if (!in_array($user->ID, $review->assigned_users)) {
  7.         return false; // review is not assigned to the user
  8.     }
  9.     if ($user->ID !== get_post()->post_author) {
  10.         return false; // user is not the page author
  11.     }
  12.     return $canRespond;
  13. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement