Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // change 99 to the ID of the Discount Code field
- add_filter("gform_field_validation_99", "custom_validation", 10, 4);
- function custom_validation($result, $value, $form, $field){
- $coupon_codes = array(
- 'NEWCUST20',
- 'RENEWCUST5',
- 'FREEFRIDAY'
- );
- $value = strtoupper($value); // make sure we are comparing apples to apples
- if (!in_array($value,$coupon_codes){
- $result['is_valid'] = false;
- $result['message'] = 'Invalid code.';
- }
- return $result;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement