Hi,
I currently have a form that checks if a certain postcode is in the serviceable area of the business. See code below:
add_filter( 'gform_field_validation_2_8', 'custom_zip_validation', 10, 4 );
function custom_zip_validation( $result, $value, $form, $field ) {
if ( $result['is_valid'] ) {
$acceptable_zips = array('1234','3332','4444','5555',);
$zip_value = rgar( $value, $field->id . '.5' );
if ( ! in_array( $zip_value, $acceptable_zips ) ) {
wp_redirect( get_permalink( 52 ) );
exit();
}
}
return $result;
}
When a postcode isn’t in the serviceable area, the user is redirected to a page telling them so. When the postcode is in the serviceable area, it goes to the confirmation page, which has another form where the user can fill out further details.
The form currently submits the entry when the postcode is in the serviceable area. But I also need it to submit an entry when its not in the serviceable area, so the business can still get the lead, and act on it in future if the postcode becomes serviceable.
Is this possible? I’d appreciate any help with a solution and my code above. Thank you!