WordPress Integration

CAPTCHA protection patterns for WordPress login, registration, comments, and WooCommerce.

Copy these patterns into your project to integrate gkCAPTCHA server-side verification.

Installation

  1. Upload the gk-captcha folder to /wp-content/plugins/
  2. Activate the plugin in WordPress admin (Plugins > Installed Plugins)
  3. Go to Settings > gkCAPTCHA
  4. Enter your Site Key and Secret Key from gatekeeper.sa
  5. Choose which forms to protect and click Save Changes

Supported Forms

FormDefaultDescription
LoginEnabledProtects wp-login.php
RegistrationEnabledProtects user registration
CommentsEnabledProtects comment submissions
Password ResetEnabledProtects lost-password flow
WooCommerce CheckoutDisabledOnly visible if WooCommerce is active

Widget Integration

The widget is rendered automatically on protected forms. For custom forms, use the HTML markup directly:

custom-form.html
<form method="POST">
    <!-- The widget appears automatically on selected forms -->
    <gk-captcha sitekey="pk_live_..."></gk-captcha>
    <button type="submit">Submit</button>
</form>

<script src="https://gkcaptcha.gatekeeper.sa/widget/gk-captcha.js" async defer></script>

AJAX Verification

For AJAX form submissions, the gk-captcha-token field is included automatically in FormData:

form.js
// JavaScript: AJAX form submission with CAPTCHA
document.getElementById('my-form').addEventListener('submit', async (e) => {
    e.preventDefault();
    const form = e.target;
    const formData = new FormData(form);

    // The gk-captcha-token field is added automatically by the widget
    const response = await fetch(form.action, {
        method: 'POST',
        body: formData,
    });

    const result = await response.json();
    if (result.success) {
        // Form submitted successfully
    }
});

Error Handling

If the gkCAPTCHA API is temporarily unreachable (network error, DNS failure, timeout, 5xx response), verification returns success and logs a warning. This is the industry-standard CAPTCHA behavior — your users are never blocked due to API outages.

إذا كانت واجهة gkCAPTCHA غير متاحة مؤقتًا، يُرجع التحقق نجاحًا ويُسجّل تحذيرًا. هذا هو السلوك القياسي — لن يُحظر المستخدمون بسبب انقطاع الخدمة.

Settings Reference

OptionDefaultDescription
Site Key(required)Public site key from gatekeeper.sa
Secret Key(required)Secret key for server-side verification
Widget URLhttps://gkcaptcha.gatekeeper.sa/widget/gk-captcha.jsURL of the gkCAPTCHA widget script
API URLhttps://gkcaptcha.gatekeeper.saBase URL for the verification API
ThemeLightWidget color scheme (light / dark)

Requirements

RequirementMinimum
WordPress6.0+
PHP8.0+
WooCommerce (optional)7.0+

No Composer required. No external PHP dependencies.