Send email when validation failed
-
Hi
I need Contact Form 7 to send one email when validation has been failed. Then send the normal CF7 email when the form is submitted correctly. Ridiculous I know but clients!
So far in functions.php I have
function send_failed_vaildation_email() { $submission = WPCF7_Submission::get_instance(); $invalid_fields = $submission->get_invalid_fields(); $posted_data = $submission->get_posted_data(); if ( !empty( $invalid_fields ) ) { $messagesend = 'Name:' . $posted_data['your-name']; $messagesend .= '\r\nEmail:' . $posted_data['email']; $messagesend .= '\r\nPhone:' . $posted_data['validPhone']; $messagesend .= '\r\nRate:' . $posted_data['rate']; $messagesend .= '\r\nBased:' . $posted_data['based']; wp_mail('e*********[email protected]', 'failed validation mail', $messagesend ); } } add_filter("wpcf7_posted_data", "send_failed_vaildation_email");
The problem is with
$invalid_fields = $submission->get_invalid_fields();
this array always returns empty, even when there are validation errors so thewp_mail()
never fires.Any ideas?
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Send email when validation failed’ is closed to new replies.