Advertisement
geminilabs

[site-reviews] Save the terms value as review meta data

Nov 19th, 2020 (edited)
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /**
  2.  * Enable the Custom Fields metabox for reviews
  3.  * @return void
  4.  */
  5. add_action('admin_init', function () {
  6.     add_post_type_support('site-review', 'custom-fields');
  7. });
  8.  
  9. /**
  10.  * Save the terms value to the review as meta data
  11.  * @param \GeminiLabs\SiteReviews\Review $review
  12.  * @param \GeminiLabs\SiteReviews\Commands\CreateReview $command
  13.  * @return void
  14.  */
  15. add_action('site-reviews/review/created', function ($review, $command) {
  16.     if (wp_validate_boolean($command->request->terms)) {
  17.         update_post_meta($review->ID, 'terms_accepted', true);
  18.     }
  19. }, 10, 2);
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement