Advertisement
designerken

GF User Defined Price Validation

Jul 22nd, 2024
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'gform_field_validation_1_22', 'gf_user_defined_price_validation', 10, 4 );
  2. function gf_user_defined_price_validation( $result, $value, $form, $field ) {
  3.     //change value for price field to just be numeric (strips off currency symbol, etc.) using Gravity Forms to_number function
  4.     //the second parameter to to_number is the currency code, ie "USD", if not specified USD is used
  5.     $number = GFCommon::to_number( $value, '' );
  6.     GFCommon::log_debug( __METHOD__ . '(): User Defined Price Submitted: ' . $number );
  7.  
  8.     if ( $result['is_valid'] && $number < 5501 ) {
  9.         $result['is_valid'] = false;
  10.         $result['message'] = 'You must enter less than $5500.00';
  11.     }
  12.     return $result;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement