review_form_rating_options
Allows changing the text of rating criteria options used in the review form.
You need to have a working knowledge of Hooks before you get started.
Parameters
Name | Type | Description |
---|---|---|
$options |
parameter |
(array) |
$params |
parameter |
(array) associative array with contextual data |
Boilerplate Code
Use the boilerplate code to start using the filter, and add your own logic to modify the first argument and return it.
Clickfwd\Hook\Filter::add('review_form_rating_options', function($options, $params)
{
// Uncomment line below to view available data passed into hook
// fwd_dd($options, $params);
return $options;
});
Examples
Replace numeric rating values with text in the review form
The code below is meant to be used for a rating scale of 5 with increments of 1.
function review_form_rating_options($options, $params)
{
$criteriaId = S2Array::get($params,'criteria_id');
$listingTypeId = S2Array::get($params,'listing_type_id');
$reviewType = S2Array::get($params,'review_type');
$required = S2Array::get($params,'required');
$scale = S2Array::get($params,'scale');
$increment = S2Array::get($params,'increment');
$options = [];
if ( !$required )
{
$options['na'] = 'N/A';
}
$options[1] = 'Terrible';
$options[2] = 'Not so bad';
$options[3] = 'Just ok';
$options[4] = 'Good';
$options[5] = 'Excellent';
return $options;
}
Clickfwd\Hook\Filter::add('review_form_rating_options', 'review_form_rating_options', 10);
Source Files
/views/helpers/review_helper.php