listing_submit_validation

Filter Hook Listings

Filter the array of validation messages.

Parameters

$validation

(array) validation messages

$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('listing_submit_validation', function($validation, $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($validation, $params);
  
  return $validation;
});
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

Skip Listing Submit Validation for Admins

Clickfwd\Hook\Filter::add('listing_submit_validation', function($validation, $params) 
{
	if (S2Object::make('auth')->admin)
	{
		return [];
	}

  	return $validation;
});

Set Minimum Required Length for Summary Field

Clickfwd\Hook\Filter::add('listing_submit_validation', function($validation, $params)
{
	$summary = S2Array::get($params,'data.Listing.introtext');
 
	$summary = strip_tags($summary);
 
	if ( mb_strlen($summary) < 100 )
	{
		$validation[] = 'The summary needs to be at least 100 characters';
	}
 
	return $validation;
}, 10);

Source

  • /admin_controllers/admin_listings_controller.php
  • /controllers/listings_controller.php