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
- Upload the
gk-captchafolder to/wp-content/plugins/ - Activate the plugin in WordPress admin (Plugins > Installed Plugins)
- Go to Settings > gkCAPTCHA
- Enter your Site Key and Secret Key from gatekeeper.sa
- Choose which forms to protect and click Save Changes
Supported Forms
| Form | Default | Description |
|---|---|---|
| Login | Enabled | Protects wp-login.php |
| Registration | Enabled | Protects user registration |
| Comments | Enabled | Protects comment submissions |
| Password Reset | Enabled | Protects lost-password flow |
| WooCommerce Checkout | Disabled | Only visible if WooCommerce is active |
Widget Integration
The widget is rendered automatically on protected forms. For custom forms, use the HTML markup directly:
<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:
// 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
| Option | Default | Description |
|---|---|---|
| Site Key | (required) | Public site key from gatekeeper.sa |
| Secret Key | (required) | Secret key for server-side verification |
| Widget URL | https://gkcaptcha.gatekeeper.sa/widget/gk-captcha.js | URL of the gkCAPTCHA widget script |
| API URL | https://gkcaptcha.gatekeeper.sa | Base URL for the verification API |
| Theme | Light | Widget color scheme (light / dark) |
Requirements
| Requirement | Minimum |
|---|---|
| WordPress | 6.0+ |
| PHP | 8.0+ |
| WooCommerce (optional) | 7.0+ |
No Composer required. No external PHP dependencies.