Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Prevent authors from submitting reviews for their own post
- * @param bool $isValid
- * @param \GeminiLabs\SiteReviews\Request $request
- * @return bool|string
- */
- add_filter('site-reviews/validate/custom', function ($isValid, $request) {
- $postIds = explode(',', $request->assigned_posts);
- foreach ($postIds as $postId) {
- $post = get_post($postId);
- if ($post && intval($post->post_author) === get_current_user_id()) {
- return __('You cannot review your own product.');
- }
- }
- return $isValid;
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement