Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Modifies the review values before they are saved
- * Paste this in your active theme's functions.php file.
- * @param array $values
- * @param \GeminiLabs\SiteReviews\Commands\CreateReview $command
- * @return array
- */
- add_filter('site-reviews/create/review-values', function ($values, $command) {
- // If the user is not logged in
- // Or, if the review was NOT submitted with the specified Review Form
- // Then abort!
- if (!is_user_logged_in() || 21084 != $command->request->form) {
- // return the unchanged values
- return $values;
- }
- // get the logged in user
- $user = wp_get_current_user();
- // get a Post ID from the provided URL
- $postId = url_to_postid('https://www.xyz.com/'.$user->user_nicename);
- // get the post object from the Post ID
- $post = get_post($postId);
- // proceed if the the post object was found; also ensure that the "geodir_get_post_meta" function exists
- if ($post && function_exists('geodir_get_post_meta')) {
- // get the region
- $region = geodir_get_post_meta($post->ID, 'region', true);
- // get the city
- $city = geodir_get_post_meta($post->ID, 'city', true);
- // get the date
- $date = do_shortcode('[geodir_event_schedules type="upcoming" number="1" template="{start_date} - {end_date}" use_current="1"]');
- // finally, change the review title
- $values['title'] = $city.', '.$region.', '.$date;
- }
- // always return the review values!
- return $values;
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement