• Resolved David Ha

    (@hathaihaojp)


    Hello, I really like this plugin, but I see that the author almost never mentioned anti-spam issues in the introduction. I often use Cloudflare Turnstile Captcha, I want to ask how can I use it with HTML Forms? Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Lap

    (@lapzor)

    I haven’t tried with other captcha services, but I did some testing on how to add a hCaptcha to HTML forms. Maybe you can work with this example and adept it to your own needs.

    1. Install and activate the hcaptcha plugin, create a free hCaptcha account and add your credentials in the hCaptcha plugin settings
    2. 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' );
    1. 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!

    Thread Starter David Ha

    (@hathaihaojp)

    Works very effectively! Great! I just learned about Hcaptcha for the first time (right after your introduction). Its design is really beautiful (haha). Thank you very much for your quick reply! Happy Thanksgiving!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cloudflare Turnstile Captcha for HTML Forms’ is closed to new replies.