Skip to main content

benecaster_buyup_price_migration_complete

Action Premium

Fires once per sweep, after every candidate grant has been processed, carrying the full outcome. Mirrors the shape of benecaster_cutoff_billing_pause_complete.

React to a buy-up price migration

Premium Beginner

When a podcaster changes a buy-up’s price, existing holders are grandfathered at their old price by default. The podcaster can instead choose to migrate them onto the new price at their own next renewal — this recipe reacts to that choice.

benecaster_buyup_subscriber_migrated fires once per subscriber successfully moved onto the new price — use it to react per subscriber, e.g. sync a CRM record or log a billing-change event.

benecaster_buyup_price_migration_complete fires once per sweep, carrying the full outcome — use it for a single summary notification instead of one per subscriber.

<?php
add_action(
    'benecaster_buyup_subscriber_migrated',
    function ( int $user_id, int $show_id, int $buyup_id, float $old_price, float $new_price ): void {
        // Log every price migration to an external system, e.g. a CRM.
        my_crm_log_price_change( $user_id, $buyup_id, $old_price, $new_price );
    },
    10,
    5
);

add_action(
    'benecaster_buyup_price_migration_complete',
    function ( int $buyup_id, int $migrated, array $skipped_billing, array $failures ): void {
        // Send your own operator alert if anything needed a second look —
        // Benecaster's own admin notice already covers this for the
        // podcaster, this is for a separate ops channel (e.g. Slack).
        if ( [] !== $failures ) {
            my_ops_alert( sprintf( '%d buy-up migrations failed for buy-up #%d', count( $failures ), $buyup_id ) );
        }
    },
    10,
    4
);

View on GitHub →

Parameters

Name Type Default Description
$buyup_id int ID of the migrated buy-up.
$migrated int Number of subscribers successfully moved onto the new price.
$skipped_billing array Subscribers skipped because their billing was already past-due or paused — never migrated or deferred, and named in an admin notice rather than silently dropped.
$failures array Subscribers whose migration attempt failed outright.

Examples

Send a summary alert when anything needed a second look

add_action( 'benecaster_buyup_price_migration_complete', function ( int $buyup_id, int $migrated, array $skipped_billing, array $failures ): void {
    if ( [] !== $failures ) {
        my_ops_alert( sprintf( '%d buy-up migrations failed for buy-up #%d', count( $failures ), $buyup_id ) );
    }
}, 10, 4 );

Notes

Benecaster's own admin notice already surfaces skips and failures to the podcaster — this hook is for a separate channel (e.g. an ops Slack). A podcaster can re-run the sweep by hand via the buy-up edit screen's "Retry price migration" link (POST /buyups/{id}/migrate), which re-fires benecaster_buyup_price_migration_requested with $old_price = 0.0. Recipe: See react-to-a-buyup-price-migration.

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