If ZIP code in the list show one form. If no - show another [RESOLVED]

Eventually I created Frankenstein but it works. :slight_smile:

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))) ) {
        add_filter( 'gform_confirmation_1', 'custom_confirmation', 10, 4 );
        function custom_confirmation( $confirmation, $form, $entry, $ajax ) {
            $confirmation = array( 'redirect' => 'https://www.google.com' );
            return $confirmation;
        }

	}else{
        add_filter( 'gform_confirmation_1', 'custom_confirmation1', 10, 4 );
        function custom_confirmation1( $confirmation, $form, $entry, $ajax ) {
            $confirmation = array( 'redirect' => 'https://www.microsoft.com' );
            return $confirmation;
        }        
    }
    return $result;

}
add_filter('gform_field_validation_1_3', 'gform_zip_checker', 10, 4); 
1 Like