Skip to main content

benecaster_set_active_bridge()

Membership Premium
benecaster_set_active_bridge( int $show_id, string $slug ): bool

Connects a show to a membership system programmatically — the same value the bridge picker in Settings → Subscription writes, so the UI reflects it on next page load.

It validates against the filtered bridge table, not a hard-coded list, so an add-on’s own slug registered through benecaster_bridges is writable exactly like a built-in one.

Parameters

Name Type Default Required Description
$show_id int Yes Show post ID. A non-positive value is refused.
$slug string Yes A registered bridge slug, or '' to clear the show's bridge.

Return Value

Type: bool

true when the value was written. falsewithout writing anything — for an unregistered slug or a non-positive show ID. Clearing with '' always succeeds.

Example

// An add-on's own setup wizard connecting the podcaster's plugin for them,
// instead of ending with "now go to Settings and pick your plugin".
if ( ! benecaster_set_active_bridge( $show_id, 'my-plugin' ) ) {
    return new WP_Error(
        'bridge_not_registered',
        __( 'That membership plugin is not available on this site.', 'my-addon' )
    );
}

Notes

Always check the return value. A refusal is returned, not thrown. Ignoring it leaves you believing you configured a bridge that was never stored — and the failure is silent right up until subscribers report they cannot get their feeds.

Registered is not the same as installed, and this function only checks registration. All four built-in bridges are registered whether or not their plugin is present, and the available callable on a registration gates what the picker offers, not what this function accepts. A true here does not tell you the membership plugin exists. If your flow needs that, check for it yourself before calling.

Passing '' clears the show's bridge and returns true. That is a real operation, not a no-op — a show with no bridge resolves every subscriber lookup to "not a subscriber".

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