review_form_rating_options

Filter Hook Reviews

Allows changing the text of rating criteria options used in the review form.

Parameters

$options

(array)

$params

(array) associative array with contextual data

You need to have a working knowledge of Hooks before you get started.

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
  // For JReviews 3.x and earlier use dd instead of fwd_dd
  // fwd_dd($options, $params);
  
  return $options;
});
Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

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

  • /views/helpers/review_helper.php