I recommend using hCaptcha.
I did some testing on how to add a hCaptcha to HTML forms:
- Install and activate the hcaptcha plugin, create a free hCaptcha account and add your credentials in the hCaptcha plugin settings
- Add the following code snippet to your website:
add_filter('hf_validate_form', function( $error_code, $form, $data ) {
$result = hcaptcha_verify_post();
if ( null !== $result ) {
$error_code = 'catcha_failed';
}
return $error_code;
},10,3);
add_filter(
'hf_template_tags',
function( $tags ) {
$tags['hcaptcha'] = do_shortcode( '[hcaptcha]' );
return $tags;
}
);
add_filter( 'hf_validate_form_request_size', '__return_false');
- add {{hcaptcha}} to your HTML-Forms fields where you want to show the captcha.
Hope that helps. If you have any questions, please let me know!