Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * This will change the post_author of a review to the first assigned user.
- * This hook is triggered immediately after the review is created but before the reviews details are saved.
- * Note: This will also trigger a post revision.
- * @param int $postId
- * @param \GeminiLabs\SiteReviews\Commands\CreateReview $command
- * @return void
- */
- add_action('site-reviews/review/create', function ($postId, $command) {
- $userId = glsr_get($command->assigned_users, 0); // get the first user ID from the assigned_users array
- if (get_user_by('id', $userId)) { // make sure the user exists
- wp_update_post([
- 'ID' => $postId,
- 'post_author' => $userId,
- ]);
- }
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement