DNAbyD3Docs
Middleware

WordPress

Run your DNA rules on every page WordPress serves, with one plugin and three lines in wp-config.php.

Install the plugin and WordPress asks DNA about each request before it serves the page, including cache hits a caching plugin serves through PHP. WordPress then does what your rules ask for, Charge and Require a human included, and an MCP server rule charges per tool call. WordPress 6.0 or later, on PHP 7.4 or later with the curl extension.

Install

  1. Download d3-dna.zip and upload it under Plugins → Add New → Upload Plugin.

  2. Activate DNA by D3.

  3. In wp-config.php, above the line that requires wp-settings.php, add your API key, the domains your site answers on, and the line that runs DNA before your page cache:

    define('DNA_API_KEY', 'your key');
    define('DNA_HOSTS', 'www.example.com,example.com');
    if (is_file(__DIR__ . '/wp-content/plugins/d3-dna/boot.php')) include __DIR__ . '/wp-content/plugins/d3-dna/boot.php';

    Tools → DNA shows these lines with your site's own path and domain. Every DNA_ setting goes above the boot.php line: DNA reads them when that line runs, so one defined below it does nothing.

  4. Open Tools → DNA and select Check the home page. pass means DNA is live.

  5. Watch the first request land in your dashboard.

To turn DNA off, add define('DNA_ENABLED', false); above the boot.php line in wp-config.php. Deactivating the plugin leaves the wp-config.php lines running.

What DNA sees

DNA checks what WordPress serves: pages, the REST API, logins and feeds. A page someone paid for is never stored by your caching plugin. Images, scripts and uploads, pages your host caches (WP Engine, Kinsta, Cloudflare APO), and pages a caching plugin serves as files (WP Rocket) reach visitors before WordPress runs. To cover those too, put DNA in front of the whole site with Cloudflare or our nameservers.

Scope rules to their paths

WordPress's own requests reach DNA like a visitor's: wp-cron.php, Site Health checks and payment webhooks. A rule that blocks No name blocks those too, so scope it to the paths it protects.

WordPress also serves a page at addresses its path doesn't match: /?rest_route=/… for /wp-json/…, other letter cases, its feed, its embed, and the REST API's posts endpoints. To charge for a page, match each address it is served at, or turn off the ones your site doesn't use.

Leave headers out of your rules

DNA reads every header and cookie for your rules. Authorization, Proxy-Authorization, and WordPress's login, post-password and WooCommerce session cookies never reach DNA. To keep others on your server, list them by name, comma-separated, in wp-config.php above the boot.php line:

ConstantKeeps back
DNA_EXCLUDE_HEADERSHeaders, by name
DNA_EXCLUDE_COOKIESCookies, by name

On this page