Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @param bool|string $isValid
- * @param \GeminiLabs\SiteReviews\Request $request
- * @return bool|string
- */
- add_filter('site-reviews/validate/custom', function ($isValid, $request) {
- if (!is_user_logged_in()) {
- return $isValid;
- }
- $postIds = $request->sanitize('assigned_posts', 'array-int');
- $userId = get_current_user_id();
- foreach ($postIds as $postId) {
- $postAuthorId = (int) (get_post($postId)->post_author ?? 0);
- if ($userId === $postAuthorId) {
- return 'You are not allowed to review your own post.';
- }
- }
- return $isValid;
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement