Documentation / Integrations · WordPress

WordPress: the plugin, or a small relay.

WordPress gives you two paths: the maintained plugin for the standard install, or a small PHP relay when you need custom placement. Both keep the secret out of the page.

Last updated

Use the plugin first. The maintained plugin lives in the separate volance-wordpress repository. This page describes the integration boundary; it does not vendor plugin code.

What the plugin handles

  • Loads /trace.js on the pages you enable and passes workspace settings from the session response.
  • Keeps the public key in page code and the secret key server-side.
  • Relays evidence through a WordPress REST route and calls the scoring API.
  • Leaves the enforcement decision to your site code or a small policy hook.

Manual relay

If you are not using the plugin, add a small REST route. Put the secret in wp-config.php or an environment variable, never in a shortcode or the block editor.

wp-config.phpServer-only
define('VOLANCE_PUBLIC_KEY', 'pk_...');
define('VOLANCE_SECRET_KEY', 'sk_...');
PHP relayREST route
add_action('rest_api_init', function () {
  register_rest_route('volance/v1', '/human-check', [
    'methods' => 'POST',
    'permission_callback' => '__return_true',
    'callback' => function (WP_REST_Request $request) {
      $evidence = $request->get_json_params();
      $ch = curl_init('https://app.volance.com/api/trace/score');
      curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_TIMEOUT_MS => 800,
        CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . VOLANCE_SECRET_KEY,
          'Content-Type: application/json',
        ],
        CURLOPT_POSTFIELDS => wp_json_encode([
          'publicKey' => VOLANCE_PUBLIC_KEY,
          'page' => $evidence['page'] ?? '/',
          'clientSignals' => $evidence['clientSignals'] ?? [],
          'events' => $evidence['events'] ?? [],
        ]),
      ]);
      $result = json_decode(curl_exec($ch), true);
      curl_close($ch);
      return [
        'action' => $result['action'] ?? 'flag',
        'score' => $result['score'] ?? null,
        'requestId' => $result['requestId'] ?? null,
      ];
    },
  ]);
});
  • Consent: start the collector only after your consent flow has run. The plugin should expose a setting that does not start collection before consent.
  • Page cache: do not cache the relay response. A cached decision is a decision you did not just make.
  • Object cache: the session manifest can be cached for its one-hour lifetime, but a fresh session per form submission is better for requestId correlation.
  • Secrets: never put sk_ in a shortcode, a theme file, or the database.

Verify it

  1. Run a consented test in the portal and compare it with a real WordPress signup.
  2. Confirm the page source contains the public key only.
  3. Submit a form and match the requestId in the portal to the relay log.
  4. Keep the policy in monitor mode until the split looks right.

Related

Free to start. 10,000 scores a month, one project, no credit card.

Get started free