Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Set the name and email values from URL parameters (?review_name=&review_email=)
- * Example: https://domain.com?review_name=Jane&review_email=jane@xxx.com
- * @param array $fields
- * @return array
- */
- add_filter('site-reviews/review-form/fields/normalized', function ($fields) {
- $parameters = array_filter([
- 'email' => filter_input(INPUT_GET, 'review_email', FILTER_VALIDATE_EMAIL),
- 'name' => filter_input(INPUT_GET, 'review_name'),
- ]);
- $haystack = wp_list_pluck(wp_list_pluck($fields, 'field'), 'path');
- foreach ($parameters as $needle => $value) {
- if (in_array($needle, $haystack)) {
- $index = array_search($needle, $haystack);
- $fields[$index]->field['value'] = $value;
- }
- }
- return $fields;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement