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.json 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 and caching
- 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
requestIdcorrelation. - Secrets: never put
sk_in a shortcode, a theme file, or the database.
Verify it
- Run a consented test in the portal and compare it with a real WordPress signup.
- Confirm the page source contains the public key only.
- Submit a form and match the
requestIdin the portal to the relay log. - Keep the policy in monitor mode until the split looks right.
Related
- Integrations — the generic relay
- Collector & consent — the browser boundary
- Operations — keys and caching
- Errors & limits — what a failed relay returns