Skip to main content

Mirror built-in tier CRUD into an external CRM, billing dashboard, or reporting pipeline

Free Intermediate Since v1.0.0

MembershipTiersController fires these three actions after each successful tier create/update/delete. Create and update receive the full hydrated tier array (tier_slug, tier_name, monthly_price, annual_price, is_free, is_active, description, tier_order, show_id); delete receives only the IDs and slug. tier_slug is immutable — treat it as the stable external key. monthly_price and annual_price are float|null (null means free-only tier).

Code

<?php
add_action( 'benecaster_membership_tier_created', function ( int $tier_id, array $tier ): void {
    my_crm_upsert_plan( [
        'external_id' => 'benecaster:' . $tier['show_id'] . ':' . $tier['tier_slug'],
        'name'        => $tier['tier_name'],
        'monthly'     => $tier['monthly_price'],
        'annual'      => $tier['annual_price'],
        'active'      => $tier['is_active'],
    ] );
}, 10, 2 );

add_action( 'benecaster_membership_tier_deleted', function ( int $tier_id, int $show_id, string $tier_slug ): void {
    my_crm_deactivate_plan( 'benecaster:' . $show_id . ':' . $tier_slug );
}, 10, 3 );

View on GitHub →

Hooks Used