Last active
January 2, 2016 02:49
-
-
Save dannyconnolly/8239359 to your computer and use it in GitHub Desktop.
Custom validation on Contact form 7 plugin
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
add_filter( 'wpcf7_validate_text', 'your_validation_filter_func', 10, 2 ); | |
add_filter( 'wpcf7_validate_text*', 'your_validation_filter_func', 10, 2 ); | |
function your_validation_filter_func( $result, $tag ) { | |
$type = $tag['type']; | |
$name = $tag['name']; | |
if ( 'your-id-number-field' == $name ) { | |
$the_value = $_POST[$name]; | |
if ( is_not_valid_against_your_validation( $the_value ) ) { | |
$result['valid'] = false; | |
$result['reason'][$name] = "Error message here"; | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment