Advertisement
geminilabs

[site_reviews] Remove email and name fields for logged-in users

Feb 25th, 2023 (edited)
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. /**
  2.  * Remove the email and name fields for logged-in users
  3.  * @return array
  4.  */
  5. add_filter('site-reviews/review-form/fields/normalized', function (array $fields) {
  6.     if (is_user_logged_in()) {
  7.         return array_filter($fields, function ($field) {
  8.             return !in_array($field->path, ['name', 'email']);
  9.         });
  10.     }
  11.     return $fields;
  12. });
  13.  
  14. /**
  15.  * Remove the email and name validation for logged-in users
  16.  * @return array
  17.  */
  18. add_filter('site-reviews/validation/rules/normalized', function (array $rules) {
  19.     if (is_user_logged_in()) {
  20.         unset($rules['name']);
  21.         unset($rules['email']);
  22.     }
  23.     return $rules;
  24. }, 100);
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement