benecaster_bridge_connected
Fires each time an admin saves a bridge selection — from both the setup wizard’s Subscription step and Settings → Subscription. This covers the initial connection, changing to a different bridge, and re-saving the same bridge. It fires on every save, not just on first connection.
This hook does not fire when the bridge is cleared with an empty slug. It is a free hook that fires regardless of license status. Common bridge slugs include `’memberpress’`, `’woocommerce-subscriptions’`, `’woocommerce-memberships’`, `’paid-memberships-pro’`, and `’restrict-content’`.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$bridge_slug |
string |
— | Slug of the bridge just connected (e.g. 'memberpress', 'restrict-content') |
$show_id |
int |
— | ID of the show |
Examples
Store metadata for each bridge level
add_action( 'benecaster_bridge_connected', function (
string $bridge_slug,
int $show_id
): void {
// Guard against repeat runs on re-save
if ( get_post_meta( $show_id, '_my_addon_bridge_initialised', true ) ) {
return;
}
update_post_meta( $show_id, '_my_addon_bridge_initialised', true );
my_addon_setup_for_show( $show_id, $bridge_slug );
}, 10, 2 );
Read all tiers from the newly connected bridge and record sync timestamps
add_action( 'benecaster_bridge_connected', function (
string $bridge_slug,
int $show_id
): void {
$levels = Benecaster\Plugin::instance()
->make( Benecaster\Bridge\BridgeManager::class )
->get_active_bridge( $show_id )
->get_all_tiers( $show_id );
foreach ( $levels as $level ) {
update_post_meta(
$show_id,
'_my_addon_level_' . sanitize_key( $level['id'] ) . '_synced',
current_time( 'mysql' )
);
}
}, 10, 2 );
Notes
Because this hook fires on every save including re-saves and bridge changes, guard any initialization logic that should run only once with a post meta flag to avoid running it multiple times. During the setup wizard flow, benecaster_bridge_connected fires first (when the bridge is selected), then benecaster_setup_wizard_completed fires when the full wizard completes.