Skip to main content

React when an admin connects a subscription bridge

Premium Intermediate

Fires each time an admin saves a bridge selection — from both the setup wizard and the Settings → Subscription tab. Use to seed bridge-specific defaults, trigger an initial membership level sync, or log the connection event. Fires on re-saves too (changing bridges); guard with a flag in post meta if the work should only run once per show.

When to Use This

benecaster_bridge_connected fires each time a bridge slug is saved, from any entry point. Use it when your add-on needs to:

  • Initialize data keyed by the connected bridge (e.g. default tier mappings, sync timestamps)

  • Log or audit bridge connection events

  • Trigger a one-time membership level pull from the newly connected plugin

This is distinct from benecaster_setup_wizard_completed — the bridge hook fires whenever the bridge is saved, not just at wizard completion.

How It Works

The action passes the connected bridge’s slug and the show ID. From there you can resolve the active bridge through BridgeManager and read its membership levels with get_all_tiers(), which is the usual starting point for seeding per-level data.

Notes

The action fires on every save, including re-saves. If a podcaster switches from MemberPress to WooCommerce Subscriptions, this hook fires twice — once for the new bridge and once if they switch back. If your initialization should only run once per show, guard it with a flag in post meta and bail when the flag is already set.

Does not fire when the bridge is cleared. Clearing the bridge selection (empty slug) does not trigger this action. Use benecaster_setup_wizard_completed or a separate admin hook if you need to react to disconnection.

$bridge_slug identifies the plugin. Common values: 'memberpress', 'woocommerce-subscriptions', 'paid-memberships-pro', 'restrict-content'. Add-ons that register custom bridges will produce their own slugs.

Related

Code

<?php
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 );

View on GitHub →

Hooks Used

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