Created
March 20, 2018 23:44
-
-
Save gareth-gillman/1f1e733485183509a193febb888b3efb to your computer and use it in GitHub Desktop.
Custom Array Validation for Contact Form 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gg_validation_filter( $result, $tag ) { | |
if ( 'your-name' == $tag[name] ) { | |
$items = array( '00','01','02' ); | |
$post_item = $_POST['your-name']; | |
if( !in_array( $post_item, $items ) ) { | |
$result->invalidate( $tag, "This is not a valid zip!" ); | |
} | |
} | |
return $result; | |
} | |
add_filter( 'wpcf7_validate_text*', 'gg_validation_filter', 20, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment