Modify Validation Messages

Instructions

Code

Filename: gppr-validation-messages.php

<?php
/**
 * Gravity Perks // GP Price Range // Modify Validation Messages
 * https://gravitywiz.com/documentation/gp-price-range/
 *
 * Instruction Video: https://www.loom.com/share/837c81c308e34858ae693d8a45d79a6e
 */
add_filter( 'gppr_validation_messages', function( $messages, $min, $max, $form_id, $field_id ) {

	$min = GFCommon::to_money( $min );
	$max = GFCommon::to_money( $max );

	$messages['min_and_max'] = sprintf( 'Please enter an amount between %s and %s.', $min, $max );
	$messages['min']         = sprintf( 'Please enter a price greater than or equal to %s.', $min );
	$messages['max']         = sprintf( 'Please enter a price less than or equal to %s.', $max );

	return $messages;
}, 10, 5 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.