Skip to main content

benecaster_addon_is_active()

Utilities Free
benecaster_addon_is_active( string $addon_slug, int|string $show_context ): bool

Answers whether an add-on may be used on a particular show, resolving two questions in order: is it granted (does this show’s license entitle it?) and is it enabled (has the podcaster left it switched on for this show?). Reads cached options only — no API call per request. Safe to call anywhere, including template files and shortcode callbacks.

Purchase is license-wide; activation is per show. A Multi-Show customer who owns an add-on can run it on shows A and B and leave it off on C, with no second purchase.

Parameters

Name Type Default Required Description
addon_slug string — Yes Add-on slug, e.g. 'guest-manager', 'analytics-dashboard', 'transcription-service'
show_context int|string — Yes REQUIRED. A show post ID, or the show's _benecaster_show_uuid. There is no default and no site-wide fallback — see the notes.

Return Value

Type: bool

true when this show's license grants the add-on and the podcaster has left it switched on for that show. Both halves must hold — except for a site-wide add-on, which has no switch and answers from the grant alone.

Example

// The show context is required. Most hooks hand you one — use it.
add_action( 'benecaster_account_sections', function ( int $show_id ) {
    if ( benecaster_addon_is_active( 'guest-manager', $show_id ) ) {
        // render guest fields
    }
} );

Notes

The second parameter is required. A call with fewer than two arguments throws an ArgumentCountError (a subclass of TypeError), not a silent false. This mirrors benecaster_is_premium() at its own per-show refactor.

If you have no show in hand, the companion is benecaster_addon_is_active_for_any_show().

A show with no license token returns false — one that has never been connected, one that was just disconnected, and a show context of 0 or any id that resolves to no show. This holds on an all-add-ons (Studio) plan too. If your code passes 0, a falsy variable or an unresolved show id, it reads as inactive: thread the real show post ID or _benecaster_show_uuid through. A connected show is unaffected.

Reading the benecaster_active_addons option directly is not equivalent. It is only the fall-through for a connected show with no cached per-show grant, and on a two-license install it holds whichever license validated last.

How "granted" is decided, in order. The show's own add-on list from the license, when one is stored, decides on its own, and an empty list means the show is entitled to nothing. Otherwise the site-wide list decides. Only when the license sent no list at all does the all-add-ons plan flag grant the add-on. So on a Studio plan, an add-on the license does not list (the CRM Sync add-ons, for example) returns false.

A site-wide add-on has no switch, so only the grant counts. An add-on registered with scope: 'site' through benecaster_register_addon() — honoured only for an add-on the license server grants every license free — returns true for every show whose license grants it, whatever the per-show switch was last set to.

Do not gate subscriber-facing content on the site-wide call.

Where to get the context. Most hooks that could need this already pass a $show_id — check the signature before assuming you have none. Where a context is genuinely nullable (benecaster_export_sheets passes $context['show_id'] as int|null during the UI render pass), that null is the one honest case for the site-wide question.

The grant half alone — for a screen that must show an add-on as owned-but-switched-off rather than hiding it — is LicenseManager::addon_is_granted().

Need this built rather than just documented? See our services →