Last active
January 9, 2017 23:51
-
-
Save TimBHowe/d25766786897632b1e73a2f371fdef8e to your computer and use it in GitHub Desktop.
Contact Form 7 - Make sure the emails in 2 different fields don't match.
This file contains hidden or 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_email*', 'custom_email_confirmation_validation_filter', 20, 2 ); | |
| function custom_email_confirmation_validation_filter( $result, $tag ) { | |
| $tag = new WPCF7_FormTag( $tag ); | |
| if ( 'your-email' == $tag->name ) { | |
| $your_email = isset( $_POST['your-email'] ) ? trim( $_POST['your-email'] ) : ''; | |
| $manager_email = isset( $_POST['manager-email'] ) ? trim( $_POST['manager-email'] ) : ''; | |
| if ( $your_email == $manager_email ) { | |
| $result->invalidate( $tag, "Your email can NOT match your manager's email." ); | |
| } | |
| } | |
| return $result; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment