Hi Guy,
When the captcha validation fails, you can return a WP_Error on the jetpack_contact_form_is_spam filter to abort the process submission and modify the contact form HTML. Example:
add_filter( 'jetpack_contact_form_is_spam', function ( $is_spam, $submission ) {
$is_captcha_valid = false; // Replace by calling your custom validation.
if ( ! $is_captcha_valid ) {
// My custom error.
$error = new \WP_Error( 'captcha_failed', __( 'CAPTCHA verification failed. Please try again.') );
// Modify the contact form HTML.
add_filter( 'jetpack_contact_form_html', function ( $format_html) use ( $error ) {
return '<pre>' . $error->get_error_message() . '</pre>' . $format_html;
} );
// Return a custom error to abort the form process submission.
return $error;
}
return false;
}, 10, 2 );
Please let me know if it works.
Hey @guyrutenberg,
That is fantastic news! We’re glad to hear you’re all set!
If you’re finding Jetpack valuable and are happy with our support, please consider leaving us a review 🙂
I’m going to mark this thread as solved. If you have any further questions or need more help, you’re welcome to open another thread here. Cheers!