Skip to content

Instantly share code, notes, and snippets.

@TimBHowe
Last active January 9, 2017 23:51
Show Gist options
  • Select an option

  • Save TimBHowe/d25766786897632b1e73a2f371fdef8e to your computer and use it in GitHub Desktop.

Select an option

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.
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