geminilabs

Untitled

Dec 3rd, 2025 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. /**
  2.  * Allow frontend response if current user is author of any assigned post of the review.
  3.  *
  4.  * @param \GeminiLabs\SiteReviews\Review $review
  5.  */
  6. add_filter('site-reviews-authors/can/respond', function (bool $canRespond, $review): bool
  7. {
  8.     if (!canRespond) {
  9.         return false;
  10.     }
  11.     foreach ($review->assigned_posts as $postId) {
  12.         if (get_post_field('post_author', $postId) === get_current_user_id()) {
  13.             return true; // user is the author of the assigned page
  14.         }
  15.     }
  16.     return false;
  17. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment