Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Set the form rating value from an URL parameter (?overall_rating=)
- * Example: https://domain.com?overall_rating=4
- * @param array $fields
- * @return array
- */
- add_filter('site-reviews/config/forms/review-form', function ($fields) {
- if (isset($fields['rating'])) {
- $rating = intval(filter_input(INPUT_GET, 'overall_rating'));
- $rating = max(0, $rating);
- if ($rating > 5) {
- $rating = 5;
- }
- $fields['rating']['value'] = $rating;
- }
- return $fields;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement