Exempt founding members from a price change, and react when one takes effect
When a podcaster moves existing subscribers to a changed tier or buy-up price, the cohort filter runs once, before any notice email. A subscription removed there is never told and never moved, so it keeps its current price for good. The other two hooks fire when the move actually happens, after the notice period.
Amounts are minor units (old_amount_cents, new_amount_cents), in $change['currency'] — whole units for zero-decimal currencies such as JPY. That differs from benecaster_buyups.price, which is dollars.
The filter only narrows. A row you add that is not on the changed price is emailed a notice that does not apply to them. When the change applies it is then skipped as not_on_price, because the apply step finds items by the old Stripe Price they carry.
Moved ≠ charged. benecaster_price_change_subscriber_applied fires when the Stripe item is switched, which is just before the renewal the notice named. The first charge at the new price comes with that renewal’s invoice.
Code
<?php
// Keep anyone who joined before launch on the price they signed up at.
add_filter(
'benecaster_price_change_cohort',
function ( array $cohort, array $change ): array {
return array_values( array_filter(
$cohort,
static fn( array $subscription ): bool =>
! get_user_meta( (int) $subscription['user_id'], 'my_founding_member', true )
) );
},
10,
2
);
// Log each move to a CRM; alert a separate ops channel if Stripe refused any.
add_action(
'benecaster_price_change_subscriber_applied',
function ( int $user_id, int $show_id, array $change ): void {
my_crm_log_price_change( $user_id, $change['item_name'], $change['old_amount_cents'], $change['new_amount_cents'], $change['currency'] );
},
10,
3
);
add_action(
'benecaster_price_change_applied',
function ( int $change_id, array $change, array $rows ): void {
$failed = array_filter( $rows, static fn( array $r ): bool => 'failed' === $r['status'] );
if ( [] !== $failed ) {
my_ops_alert( sprintf( '%d subscribers could not be moved on price change #%d', count( $failed ), $change_id ) );
}
},
10,
3
);
Hooks Used
Need this built rather than just documented? See our services →