geminilabs

[site-reviews] Include the Accepted Terms with the creation date as the value on privacy export

Oct 20th, 2021 (edited)
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. /**
  2.  * Add the Accepted Terms data to the review
  3.  *
  4.  * @param array $data
  5.  * @param \GeminiLabs\SiteReviews\Review $review
  6.  * @return array
  7.  */
  8. add_filter('site-reviews/personal-data/export', function ($data, $review) {
  9.     $name = 'Terms Accepted';
  10.     if (false !== array_search($name, wp_list_pluck($data, 'name'))) {
  11.         // The Accepted Terms date has already been added to the export
  12.         return $data;
  13.     }
  14.     // If the terms were accepted when the review was submitted, use the review creation date as the value
  15.     $value = $review->terms ? $review->date_gmt : false;
  16.     // Set the Accepted Terms date to the export data
  17.     $data[] = ['name' => $name, 'value' => $value];
  18.     return $data;
  19. }, 10, 2);
Add Comment
Please, Sign In to add comment