benecaster_get_active_bridge_slug()
benecaster_get_active_bridge_slug( int $show_id ): string
Answers which membership system a show is connected to. Built-in slugs are memberpress, woo-subscriptions, paid-memberships and restrict-content; a third-party bridge registered through benecaster_bridges contributes its own, so do not treat the built-in four as a closed set.
Pair it with benecaster_set_active_bridge(), which writes the same value.
Parameters
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
$show_id |
int |
— | Yes | Show post ID. |
Return Value
Type:
string
The slug of the subscription bridge this show is using, or an empty string when none is configured. Also empty for a non-positive $show_id. Never null.
Example
$slug = benecaster_get_active_bridge_slug( $show_id );
if ( '' === $slug ) {
// Nothing connected yet — offer to set one up.
return;
}
if ( 'memberpress' === $slug ) {
// Register the hooks that only make sense for this bridge.
}
Notes
This is the answer to "which bridge is active", not a handle on the bridge itself. Reading the stored value rather than resolving a BridgeInterface is deliberate: it is correct before the plugin container has booted, and an add-on that only wants to branch on which bridge is in use should not have to know the interface's shape to do it.
An empty string means "not configured", and that is not an error. There is no placeholder object to test for and no null to guard — '' === benecaster_get_active_bridge_slug( $show_id ) is the whole check.
A configured slug does not mean the membership plugin is installed. The slug is whatever was last written; nothing re-validates it when a plugin is deactivated. If your code depends on the plugin actually being there, check for it yourself.
Need this built rather than just documented? See our services →