Turnstile CAPTCHA For WooCommerceTurnstile CAPTCHA For WooCommerce
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start
    • Features
    • Installation
    • First-Time Setup
    • Get Turnstile Keys
    • Onboarding Wizard
  • Settings

    • Settings Overview
    • API Settings
    • General
    • Design Studio
    • Conditional Rules
    • Per-Form Config
    • Notifications
  • Supported Forms

    • All Supported Forms
    • WooCommerce Forms
    • WordPress Forms
    • Third-Party Form Plugins
    • Checkout Blocks
    • Shortcode
  • Protection & Monitoring

    • Analytics Dashboard
    • Rate Limiting
    • Recovery URL
    • Email Digest
    • Webhooks
  • Developer

    • REST API
    • Filters & Hooks
    • Site Health
  • Compare

    • vs reCAPTCHA
    • vs hCaptcha
  • Help

    • Troubleshooting
    • FAQ
    • Glossary
Support
Buy Now
View Demo
  • Getting Started

    • Introduction
    • Quick Start
    • Features
    • Installation
    • First-Time Setup
    • Get Turnstile Keys
    • Onboarding Wizard
  • Settings

    • Settings Overview
    • API Settings
    • General
    • Design Studio
    • Conditional Rules
    • Per-Form Config
    • Notifications
  • Supported Forms

    • All Supported Forms
    • WooCommerce Forms
    • WordPress Forms
    • Third-Party Form Plugins
    • Checkout Blocks
    • Shortcode
  • Protection & Monitoring

    • Analytics Dashboard
    • Rate Limiting
    • Recovery URL
    • Email Digest
    • Webhooks
  • Developer

    • REST API
    • Filters & Hooks
    • Site Health
  • Compare

    • vs reCAPTCHA
    • vs hCaptcha
  • Help

    • Troubleshooting
    • FAQ
    • Glossary
Support
  • Getting Started

    • Introduction
    • Quick Start — Turnstile Live in 5 Minutes
    • Features — Everything the Plugin Can Do
    • Installation — Full Setup Guide
    • First-Time Setup
    • Get Turnstile Keys from Cloudflare
    • Onboarding Wizard
  • Settings

    • Settings Overview — All 9 Tabs
    • API Settings Tab
    • General Settings Tab
    • Design Studio Tab
    • Conditional Rules Tab
    • Per-Form Config Tab
    • Notifications Tab
  • Supported Forms

    • All Supported Forms
    • WooCommerce Forms
    • WordPress Forms
    • Third-Party Form Plugins
    • Checkout Blocks Integration
    • Shortcode — Drop the Widget Anywhere
  • Protection & Monitoring

    • Analytics Dashboard
    • Rate Limiting — Auto-Lockout for Abusive IPs
    • Recovery URL — Unlock a Stuck IP
    • Email Digest
    • Webhooks — Real-Time Alerts on Bot Spikes
  • Developer

    • REST API
    • Filters & Hooks
    • Site Health Integration
  • Compare

    • Turnstile vs Google reCAPTCHA
    • Turnstile vs hCaptcha
  • Help

    • Troubleshooting
    • Frequently Asked Questions
    • Glossary

Shortcode — Drop the Widget Anywhere

Use the shortcode when you need Turnstile on a form the plugin does not have a built-in toggle for — a custom MailChimp sign-up, a theme-built form, a page builder widget, etc.

Quick Use

Drop this in any page, post, widget, or template:

[wkcft-turnstile]

The widget renders with your current global settings (General + Design Studio).

Shortcode in CF7

For Contact Form 7 forms, use the dedicated variant:

[cf7-turnstile]

It hooks into CF7's validation API to block failed submissions correctly.

Attributes

All attributes override global defaults only for this shortcode instance.

AttributeValuesOverrides
themelight · dark · autoTheme
sizenormal · compact · flexibleSize
languageen · fr · de · es · it · pt · ja · zh · ar · ru · hi · autoLanguage
classany class namesAdds extra CSS classes
idany stringSets custom DOM id
actionany stringPassed to Cloudflare for analytics attribution
appearancealways · interaction-only · executeVisibility mode

Examples

Default Widget

[wkcft-turnstile]

Dark, Compact, French

[wkcft-turnstile theme="dark" size="compact" language="fr"]

Invisible (Execute Mode)

Silent background verification — user sees nothing unless Cloudflare detects a bot.

[wkcft-turnstile appearance="execute"]

With Custom CSS Class for Styling

[wkcft-turnstile class="my-custom-widget newsletter-captcha"]

With Analytics Action Name

Lets you filter Turnstile's Cloudflare analytics by form.

[wkcft-turnstile action="newsletter-signup"]

Typical Placements

Inside a Post or Page

Just type the shortcode in the editor. Gutenberg renders a Shortcode block; Classic editor renders it inline.

In a Text Widget

Appearance → Widgets → Text widget → paste shortcode.

In a Theme Template File

Inside a PHP template:

<?php echo do_shortcode('[wkcft-turnstile]'); ?>

Inside a Form Plugin That Accepts Shortcodes

Most page builders (Elementor, Beaver Builder, Divi) have a Shortcode widget/module. Drop the shortcode there.

For form plugins that do NOT support shortcodes inside form fields, use the built-in handlers on the WooCommerce Forms tab instead.

Token Submission

For the widget to work on a custom form, the form must submit the Turnstile token to your server. The token is the value of an input named cf-turnstile-response.

When the shortcode renders, it adds this input automatically — it sits inside the widget wrapper. When the user completes the CAPTCHA, Cloudflare populates the input value. When the form posts, the token goes with it.

If your form uses AJAX, you need to grab the token manually:

const token = document.querySelector('input[name="cf-turnstile-response"]').value;
// then send `token` in your AJAX payload

Then validate server-side by calling WKCFT_Validator::wkcft_check($token, 'my-custom-form').

Full validation example: REST API.

Server-Side Validation for Custom Forms

If your form is handled by your own code:

if (isset($_POST['cf-turnstile-response'])) {
    $result = WKCFT_Validator::wkcft_instance()->wkcft_check(
        sanitize_text_field($_POST['cf-turnstile-response']),
        'my-custom-form'
    );
    
    if (!$result['success']) {
        wp_die('CAPTCHA failed: ' . esc_html($result['error-codes'][0] ?? 'unknown'));
    }
}

$result shape:

[
  'success' => true|false,
  'error-codes' => ['missing-input-response', ...]  // only on failure
]

Shortcode Rendered HTML

For reference, the shortcode outputs:

<div class="wkcft-turnstile wkcft-shortcode YOUR_CUSTOM_CLASS" id="YOUR_ID" style="WRAPPER_STYLE">
  <!-- optional label -->
  <div class="cf-turnstile"
       data-sitekey="..."
       data-theme="light"
       data-size="normal"
       data-language="auto"
       data-appearance="always"
       data-action="YOUR_ACTION">
  </div>
  <!-- optional helper text -->
</div>

Multiple Widgets Per Page

You can place multiple shortcodes on the same page. Each renders a fresh widget with its own token. IDs are auto-generated unique if you do not pass id.

Styling the Widget

Target .wkcft-turnstile in your theme CSS to tweak placement and spacing. Pass a class attribute in the shortcode to add a context-specific hook:

[wkcft-turnstile class="newsletter-captcha"]

Then in CSS:

.wkcft-turnstile.newsletter-captcha { margin-top: 16px; }

Troubleshooting

ProblemFix
Shortcode outputs literal text [wkcft-turnstile]Plugin not active, or context does not execute shortcodes (e.g., a plain text-only widget)
Widget renders but form submits without validationYour form handler does not call WKCFT_Validator::wkcft_check() — add manual validation
"Invalid sitekey"Domain not in your Cloudflare widget's hostname list
Shortcode inside a repeater field shows multiple "Invalid sitekey"Known Cloudflare limitation — you need unique widget IDs. Use the id attribute: [wkcft-turnstile id="widget-1"]

Related Pages

  • Third-Party Form Plugins — Built-in handlers for CF7, WPForms, Gravity, etc.
  • General Settings — Global defaults this can override
  • Design Studio — Default styling
  • REST API — Programmatic token verification
  • Filters & Hooks — Customize widget classes + validation
Prev
Checkout Blocks Integration