Skip to main content

benecaster_membership_tiers_reordered

Action Premium

Fires after the Memberships → Tiers list saves a new tier order — every drag or keyboard reorder auto-saves through this.

Fires once per reorder, never per tier, and not at all when the submitted order matches the stored one or the tiers submitted don’t exactly match the show’s tiers. benecaster_membership_tier_updated does not fire for a reorder.

By the time this fires, the new order is saved in $tier_ids order and the show’s feed cache has already been cleared. Rank is a tier’s position in $tier_ids, which is also what [benecaster_tier_gate] compares — use the index, never a raw tier_order value.

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

Premium Intermediate

These actions fire after each successful tier create, update, delete, and reorder. 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).

A reorder on Memberships → Tiers fires benecaster_membership_tiers_reordered once for the show — never benecaster_membership_tier_updated per tier. Rank is a tier’s position in the $tier_ids array (0 = lowest), not a raw tier_order value.

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

// A reorder on Memberships → Tiers fires this once for the show, NOT
// benecaster_membership_tier_updated per tier. Rank = position (0 = lowest).
add_action( 'benecaster_membership_tiers_reordered', function ( int $show_id, array $tier_ids ): void {
    foreach ( $tier_ids as $rank => $tier_id ) {
        my_crm_set_plan_rank( $show_id, $tier_id, $rank );
    }
}, 10, 2 );

View on GitHub →

Parameters

Name Type Default Description
$show_id int ID of the show whose tiers were reordered.
$tier_ids int[] The new order, lowest rank first.
$previous_ids int[] The order immediately before this reorder.

Examples

Sync tier rank to an external CRM after a reorder

// A reorder on Memberships → Tiers fires this once for the show, NOT
// benecaster_membership_tier_updated per tier. Rank = position (0 = lowest).
add_action( 'benecaster_membership_tiers_reordered', function ( int $show_id, array $tier_ids ): void {
    foreach ( $tier_ids as $rank => $tier_id ) {
        my_crm_set_plan_rank( $show_id, $tier_id, $rank );
    }
}, 10, 2 );

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