There was a problem with the display of notifications about the successful submission of the form. Wrote a custom handler wpcf7_before_send_mail.

add_filter( 'wpcf7_before_send_mail', 'wpcf7_before_send_mail_start_function' ); function wpcf7_before_send_mail_start_function($cf7) { $log = "info.log"; $FORMID = 0000; $SECRET = "some secret key"; // если форма на главной и секретный ключ не заполнен if (($cf7->id === $FORMID) && ($_POST['secret'] !== $SECRET)) { // меняем адрес на несуществующий $mail=$cf7->prop('mail'); if($mail){ $mail['recipient']="fail@mail.com"; $cf7->set_properties(array('mail'=>$mail)); $info = $cf7->id . '///' . $_POST['secret'] . '///' . $cf7->prop('mail')['recipient']; error_log($info, 3, $log); } } return true; } 

In the event of a discrepancy or lack of a key, send a letter to a non-existent address. If the key matches, then send to the specified address.

After submitting, the letter arrives in the mail (with the correct key, of course). But no notification of successful submission is displayed. In this case, if some field is filled incorrectly and the sending was not carried out, notifications are shown.

What could be the problem?

UPD: When submitting a form, a hidden ajax-error block appears with an error

JSON.parse: unexpected character at line 1 column 1 of the JSON data

  • Where is the fix file? The same problem ( - Sergey

1 answer 1

The problem was in ($ cf7-> id === $ FORMID). Replaced it with ($ cf7-> id () === $ FORMID) and all good.