WordPress Integration

Protect your WordPress forms with SilentShield. Works with Contact Form 7, WPForms, Gravity Forms, and any custom forms.

1. Add the Script

Add this code to your theme's functions.php or use a plugin like 'Insert Headers and Footers':

functions.phpphp
// functions.php
function silentshield_enqueue() {
    wp_enqueue_script(
        'silentshield',
        'https://api.silentshield.io/client.js?key=YOUR_API_KEY',
        array(),
        null,
        true
    );
    wp_add_inline_script('silentshield', "
        document.addEventListener('DOMContentLoaded', function() {
            SilentShield.init({ apiKey: 'YOUR_API_KEY' });
        });
    ");
}
add_action('wp_enqueue_scripts', 'silentshield_enqueue');

2. Server-Side Verification

Add nonce verification to your form handler. For custom forms, add this to your processing function:

PHPphp
function verify_silentshield_nonce() {
    $nonce = sanitize_text_field($_POST['ss_nonce'] ?? '');
    if (empty($nonce)) {
        wp_die('Missing verification', 'Error', array('response' => 422));
    }

    $response = wp_remote_post('https://api.silentshield.io/api/v1/captcha/verify-nonce', array(
        'headers' => array(
            'Content-Type' => 'application/json',
            'X-Api-Key' => SILENTSHIELD_API_KEY,
        ),
        'body' => wp_json_encode(array('nonce' => $nonce)),
        'timeout' => 5,
    ));

    if (is_wp_error($response)) {
        return; // fail open
    }

    $body = json_decode(wp_remote_retrieve_body($response), true);
    if (($body['verdict'] ?? '') === 'bot') {
        wp_die('Bot detected', 'Forbidden', array('response' => 403));
    }
}

Contact Form 7

The widget automatically detects Contact Form 7 forms. No additional configuration needed — just add the script and the widget will protect all CF7 forms on the page.

WPForms / Gravity Forms

SilentShield automatically detects forms from WPForms, Gravity Forms, and other popular form plugins. The widget injects the nonce into any form it finds on the page.

Storing the API Key

Add your API key to wp-config.php for security:

wp-config.phpphp
// wp-config.php
define('SILENTSHIELD_API_KEY', 'your-api-key-here');