Update:
Super close to accomplishing, but I am facing an issue. When users enter the correct zip it works as it should, but if they enter the wrong zip code, it just gives me a never ending orange circle (I guess trying to validate it). Thing is, it works on the gravity forms “preview” sections, but not on the live site.
This is the code:
add_filter( 'gform_field_validation_2_48', 'custom_validation', 10, 4 );
function custom_validation( $result, $value, $form, $field ) {
$url = 'https://domain.com/sorry/';
$acceptable_zips = array(
'10026',
'10027', (here I included a list of all acceptable codes, took them out to make it shorter)
);
$zip_value = rgar( $value, $field->id . '.5' );
// zip validation
if ( ! in_array( $zip_value, $acceptable_zips ) ) {
// failed validation, just redirect
wp_redirect( $url );
exit;
}
// passed validation, continue with the form validation for other fields
return $result;
}