Make multiple webhooks optionals
Since 2.4.0 we accept multiple webhooks in every contact form: just add one webhook per line in “Webhook URL” settings.
We will trigger one webhook by time.
If one of them fail, the next WILL NOT be trigged.
To make webhooks optionals (not stop when fails) you should:
Not sure where to put the code? See Add custom code.
-
Return any error messages:
add_filter( 'ctz_trigger_webhook_error_message', '__return_empty_string' ); -
Trigger errors at end (optional):
add_action( 'ctz_trigger_webhook_errors', 'example_ctz_trigger_webhook_errors', 10, 2 ); function example_ctz_trigger_webhook_errors( $errors, $contact_form ) { // Here you can use $errors to get exception messages // $errors is a array of 'webhook' (the URL) and 'exception' (the catched one) $submission = WPCF7_Submission::get_instance(); $submission->set_status( 'mail_failed' ); $submission->set_response( $contact_form->message( 'mail_sent_ng' ) ); }