Validate ZIP Code against a list of codes in array

I have a client that offers services in certain areas, and charges certain prices. So I would like clients to:

  1. Enter a Zip Code
  2. If the Zip matches a service area Zip Code, allow them to continue to fill out the rest of the form.

The following code is not working for me.

add_filter( 'gform_field_validation_1_2', '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;
}
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.