The action will receive everything from wp_remote_post call and you can check it in details on wp_remote_request documentation.
add_action( 'ctz_post_request_result', 'example_ctz_post_request_result' );
function example_ctz_post_request_result( $result ) {
$body = ( ! empty( $result['body'] ) ) ? $result['body'] : [];
// You have a body now... Do what you want to do.
// I didn't try this code.
// But... you can do something like that:
$submission = WPCF7_Submission::get_instance();
$submission->set_status( 'mail_sent' );
$submission->set_response( 'The message you want...' );
}
Change “mail_sent” for any status you want. A list from CF7 code:
- validation_failed
- acceptance_missing
- spam
- mail_sent
- mail_failed
Or just throw a exception if you want to add a custom error.