WP Consent API explained: what it does and why
What the WordPress Consent API is, how plugins use wp_has_consent() to respect the cookie banner, and how Omea Consent passes every choice to it.
The WP Consent API is a shared standard for WordPress: one plugin – the consent banner – records the visitor’s choice, and any other plugin can ask “may I use statistics cookies for this visitor?” without knowing which banner you use. It started as a feature plugin and is used by a growing number of plugins.
How it works
The API defines consent categories – functional, preferences, statistics, statistics-anonymous and marketing – and two sides:
- The consent management plugin (your banner) declares itself to the API and stores each choice with
wp_set_consent(). - Other plugins check the choice before setting cookies or loading trackers.
In PHP that check looks like this:
if ( function_exists( 'wp_has_consent' ) && wp_has_consent( 'marketing' ) ) {
// Safe to load the marketing feature for this visitor.
}
The API also offers the same check in JavaScript for code that runs in the browser.
What Omea Consent does
Omea Consent is a full WP Consent API consent manager:
- It registers with the API and sets the consent type to opt-in – nothing optional is allowed until the visitor agrees.
- It bundles the API library and loads it only when the WP Consent API plugin isn’t already active, so you don’t need to install anything.
- On every choice it calls
wp_set_consent()forfunctional,statisticsandmarketingwithallowordeny.
The API stores the choice in its own cookies (wp_consent_functional, wp_consent_statistics, wp_consent_marketing), which the API sets with its default lifetime of 30 days. They are listed in Omea’s cookie catalogue as necessary.
Category mapping
| Omea category | WP Consent API category |
|---|---|
| Functional | functional |
| Statistics | statistics |
| Marketing | marketing |
| Necessary | always allowed – not sent |
When it matters
Plugins that support the Consent API follow your banner automatically – no extra script rules needed. For plugins that don’t, use Omea’s other tools: paste their tracking code into Scripts, or turn on auto-blocking.
Frequently asked questions
Do I need to install the WP Consent API plugin?
No. Omea Consent bundles the API and loads it when the WP Consent API plugin isn’t installed. If you already have the plugin, Omea uses it instead.
Which categories does Omea Consent set in the Consent API?
functional, statistics and marketing – each set to allow or deny on every change. Necessary is always allowed and isn’t sent.
Does the Consent API block scripts by itself?
No. It only shares the visitor’s choice. Each plugin decides what to do with it, so a plugin that doesn’t check the API won’t be affected.