Skip to content

Conversation

@jcedmiston
Copy link

@jcedmiston jcedmiston commented Dec 11, 2025

Added support for Cloudflare Turnstiles as a third spam prevention option for a site I help maintain. Figured it might be something others would like too!

I tried to make the formatting similar to the existing code base and added new @since tags for functions as what the next version would be at the time of this pull request.

If I need to make any adjustments or anything else, I'm happy to.

Added Cloudflare Turnstile as a third alternative to spam prevention.
Fixed disable and enable callbacks
added language assignment in display class before access in hcaptcha class.
fixed capitalization in class-health
@tw2113
Copy link
Member

tw2113 commented Dec 11, 2025

Good day @jcedmiston

We've definitely had Turnstile on our radar but had not proverbially executed on it quite yet.

Definitely appreciate the PR and submission with this. We're going to review and keep the PR in mind for when we decide to roll Turnstile in with a release. It's definitely not going to be a 2.15.1 release though, but we'll adjust the details that time.

@jcedmiston
Copy link
Author

@tw2113 Makes sense, I certainly don't want to mess with your roadmap. Thanks for taking the time to review.

@daveromsey
Copy link
Contributor

Hi @jcedmiston, thank you for the PR!

I've been testing it, and while it looks good overall, I've not been able to get a form to submit using the keys provided when I set up a free Turnstyle account or the keys provided here for testing: https://developers.cloudflare.com/turnstile/troubleshooting/testing/

image

It's looking like $data['cf-turnstile-response'] is not set here: https://github.com/WebDevStudios/constant-contact-forms/pull/788/files#diff-80099919add04c7ced1c8b2b4ed7d36dfbe545fe844c7119f9624cdadb686072R350

Could you please check this out and confirm that the test keys from Cloudflare work?

@jcedmiston
Copy link
Author

jcedmiston commented Dec 12, 2025

Hi @daveromsey! Yes, I have successfully used both the test keys and production keys. From your screenshot, the problem is probably upstream of $data['cf-turnstile-response'], and that's just a symptom.

When testing, you should see the Cloudflare challenge and the associated response in the source as pictured below:
image

If you aren't seeing the challenge, it may be that the ctct-plugin-turnstile.min.js file is not being loaded properly, as that is the file that actually calls the Turnstile render method. If the challenge isn't loaded, the response token from Cloudflare won't be set. Are you getting any errors in the console related to the ctct-plugin-turnstile.min.js file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants