(Wordpress) Contact Form 7 abort in before_send_mail filter (Wordpress) Contact Form 7 abort in before_send_mail filter wordpress wordpress

(Wordpress) Contact Form 7 abort in before_send_mail filter


You can skip the mail by using:

add_filter( 'wpcf7_skip_mail',  '__return_true' );

Since you've disabled the javascript with

add_filter( 'wpcf7_load_js', '__return_false' );

then you can use:

add_filter( 'wpcf7_form_response_output', 'wpse_form_response_output', 10, 4 );

within your wpcf7_before_send_mail action callback, where your custom error response is:

function wpse_form_response_output( $output, $class, $content, $object ){    return sprintf(        '<div class="wpcf7-response-output wpcf7-display-none wpcf7-mail-sent-ng"             role="alert" style="display: block;">%s</div>',        __( 'SOAP ERROR - Mail not sent!' )    );}