Turnstile for Elementor Pro forms

brkicpc

New member
Hi,

I needed Turnstile on Elementor Pro's Form widget, which the plugin doesn't cover yet, so I built it as a module in the style of your existing Turnstile ones, against 1.10.0. Sharing it in case you want it.

What it does:
  • Injects the widget into Elementor Pro forms at render time, just before the submit button. Skips the editor/preview and any form that already has its own captcha field.
  • Validates on submit through your existing verifyTurnstileResponse() plumbing, failing closed. One trap worth flagging: Elementor only blocks the submission when $ajax_handler->errors is non-empty, so add_error_message() alone shows the visitor an error while the email still sends. An empty-id add_error('', '') alongside it is what actually stops the send.
  • Adds an "Elementor" checkbox to the Contact forms group of your Turnstile settings via the app_for_cf_turnstile_forms filter, off by default.
It's running in production on several sites now (Elementor Pro 4.2.x, App for Cloudflare 1.10.0, WordPress 6.9): the widget renders once per form, tokenless and garbage-token POSTs to admin-ajax.php are rejected before the submit actions run so no email goes out, real submissions deliver normally, and cached pages behave.

One heads-up from along the way: Turnstile/MetForm.php hardcodes id="cf-turnstile", so on a page with more than one MetForm only the first widget renders. The per-widget id approach in this module fixes the same problem.

Happy to restructure it (say as a proper turnstile field type instead of auto injection) if you'd rather.

Thanks for the plugin, it's doing a lot of work for us.
 

Attachments

Last edited:
Thanks... Skimming it, I don't see why we couldn't include this in the next version. Less than ideal that I'm kind of running blind without access to an Elementor Pro setup, but I'll just defer to you saying it works.
 
Back
Top