Turnstile throws: Human verification failed for this form, please try again

Hoping someone can help me with turnstile. I had disabled the contact page due to massive spam attacks a few years ago and I just read about turnstile of recent. I am trying to enable it, but failed to get it to work. I do not see the verify you are human button on my contact page. Testing the contact page, I get this erorr when I submit.

Human verification failed for this form, please try again

The log shows

[2025-09-21 04:13:51] grav.DEBUG: Turnstile validation - entire form data: ["name","email","message"] [] []
[2025-09-21 04:13:51] grav.DEBUG: Turnstile validation - raw POST data keys: ["data","cf-turnstile-response","__form-name__","__unique_form_id__","form-nonce"] [] []
[2025-09-21 04:13:51] grav.DEBUG: Turnstile validation - token present: NO [] []
[2025-09-21 04:13:51] grav.WARNING: Turnstile validation failed: missing token response [] []
[2025-09-21 04:13:51] grav.WARNING: Form Captcha (turnstile) validation failed: [/contact] Details: {"error":"missing-input-response"} [] []

I did create a widget at cloudflare and have inputted my keys under form:

turnstile:
  theme: light
  site_key: 0xxxxxxd3J
  secret_key: 0x4xxxxx7_1PQ

Added these in my form.md
.
.
.

        - name: message
          label: Message
          size: long
          placeholder: Enter your message
          type: textarea
          validate:
            required: true
            pattern: '^((?!https?:\/\/)(?:\R|.))*$'
            message: 'Links not allowed.'

        - name: captcha
          type: turnstile
          theme: light

.
.
.
.

    process:
        - turnstile: true
        - email:
            from: "{{ config.plugins.email.from }}"

I have also added these from above suggestion with no go output.

  {% block javascripts %}
    {% do assets.addJs('https://challenges.cloudflare.com/turnstile/v0/api.js', {'priority':130, 'loading': 'defer'}) %}
	{% include 'partials/statCounter.html.twig' %}

  {% endblock %}
  {{ assets.js() }}

Set this to false

  js_pipeline_include_externals: false

Lastly, I am using the Receptar theme which has not been updated since 5 years ago.

OK! I got it working. After many try and error plugging in codes. It boiled down to quotation marks. I only needed to add this line to the base.html.twig file AND with no quotes for the last statement. Like this.

  {% block javascripts %}
    {% do assets.addJs('https://challenges.cloudflare.com/turnstile/v0/api.js', {priority:130, loading: defer}) %}
	{% include 'partials/statCounter.html.twig' %}

  {% endblock %}
  {{ assets.js() }}
2 Likes

I’m glad you solved this. I feel partly responsible because you may have seen my suggestion in a recent thread to use Turnstile.

However, I’m curious and I don’t really understand a few things. I just checked an implementation I have (I have a few but haven’t set up a new one for a long time) and I never added the JS block you did. I’m sure the form plugin does this for you.

Which suggestion?

Which line did you add? Do you mean you removed the quotes around the paarmeters you passed with assets.addJS?

It might be helpful for someone in future to explain these things because I found your solution confusing.

This is getting off-topic, but I built a site based on Receptar about two years ago. I found the theme lacking a few features and it had a few bugs too. I built a child theme and overrode many of the templates and also added new ones. I think most of my changes could be integrated into the official theme. I think I had a plan to make a public fork and move those changes into my fork, but other priorities came up. Thank you for reminding me!

If you are interested and don’t mind waiting a little while, I have some time for this now. I think I can produce an updated version by going through all of the differences and merging the ones that have general use into the base Receptar theme.

1 Like

hi,
I’d be interested in the Receptar-fixes aswell.

best,
salvador

(found this thread because I was looking to fix turnstile not loading · Issue #611 · getgrav/grav-plugin-form · GitHub - maybe there is a general problem with cloudflare’s js not loading?)

There were a few suggestions on how to get the Turnstile working from the other thread before the mod have split up the thread.

These were the suggestions.

Change this line to false. Default is true.
system.yaml

assets:
  js_pipeline_include_externals: false

Add this line in base.html.twig. The original suggestion had single quotes for priority & loading. Apparently, my setup of grav didn’t like that. So I had to remove them. The working code is below.

{% do assets.addJs('https://challenges.cloudflare.com/turnstile/v0/api.js', {'priority:130', 'loading: defer'}) %}

working code

  {% block javascripts %}
    {% do assets.addJs('https://challenges.cloudflare.com/turnstile/v0/api.js', {priority:130, loading: defer}) %}
.
.
.

  {% endblock %}

I built a child theme and overrode many of the templates and also added new ones.

Yes, my Receptar also have a child theme possibly the same reason you have created one as well. If you could merge your changes to the Receptar would be great. I use most of the stock. Wish getgrav could have fixed the Instagram plugin, but it was removed due to Instagram changes.

The Receptar is quite outdated, but it fitted my need at the time of install. Though I am am looking at the Mundana theme as an update. Looks great. Just figuring out how to implement my 360 panorama into the theme using iframe or such.

1 Like