Hello! My client wants to receive a form which when entering ZIP postcode (which is in the list) displays the order form. If there is no ZIP in the list, the contact form displays.
/**
* gform zip code validator.
*/
function gform_zip_checker($result, $value, $form, $field) {
$file = get_stylesheet_directory_uri().'/zips.txt'; // I have this in my child theme
if ( $result['is_valid'] && (!preg_match('/^' . $value . '$/m', file_get_contents($file))) ) {
$result['is_valid'] = false;
$result['message'] = 'We don\'t provide service to this area. If you believe this is incorrect please call us.';
}
return $result;
}
add_filter('gform_field_validation_2_8', 'gform_zip_checker', 10, 4); // gform_field_validation_FORMID_FIELDID
Should I create two another different forms and how I can call it using that example code?
My current idea is use gform_confirmation() but I have no idea about check the form field, not form id. My form ID is 1, and ZIP code field is 3. That code isn’t work: