Hi!
Well… maybe a connection problem?
I’m launching today the 1.4.0 version.
It will have new hooks and actions to allow users process webhook errors and show a error in form.
For example, if WordPress throws a Exception (error) in connection it will show the error in form. If you want show a error in another case (if Zapier return 404, for example) you should use “ctz_post_request_result” action.
For example, this code will check for response code 404 and return a error.
add_action( 'ctz_post_request_result', 'example_ctz_post_request_result' );
function example_ctz_post_request_result( $result ) {
$response = ( ! empty( $result['response'] ) ) ? $result['response'] : [];
if ( ! empty( $response['code'] ) && $response['code'] === 404 ) {
throw new Exception( 'Integration returned 404 error.' );
}
}
If you want to show this error to user, add this filter to change the default form message:
add_filter( 'ctz_trigger_webhook_error_message', 'example_ctz_trigger_webhook_error_message', 10, 2 );
function example_ctz_trigger_webhook_error_message( $message, $exception ) {
return $exception->getMessage();
}
Thanks, but the thing is that the form works well (always sends to database and e-mails), so i wouldnt want to show an error when the problem is only with the conection to zapier.
You can change to do something like send mail to you or just log.
Anyway, the new version will not change your flow (if it’s not a case of request failure). If you want to ignore even the errors in WordPress request and don’t need to user resend data, just add this to your functions.php
:
add_filter( 'ctz_trigger_webhook_error_message', '__return_empty_string' );
-
This reply was modified 5 years, 5 months ago by
Mário Valney.