Skip to main content

benecaster_price_change_cohort

Filter Premium

Filters the subscriptions a scheduled tier or buy-up price change will notify and, after the notice period, move. Runs once, at scheduling, before any notice email goes out. A subscription removed here is neither told about the change nor moved by it — it keeps its current price for good.

Parameters

Name Type Default Description
$cohort array — `benecaster_subscriptions` rows the change currently applies to.
$change array — The change row being scheduled.

Returns: array

Examples

Keep founding members 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
);

Notes

This filter only narrows the cohort. Adding a subscription that is not on the changed price gets it a notice that does not apply to it — when the change applies, that row is then skipped as not_on_price, because the apply step finds items by the old Stripe Price they carry. Recipe: Exempt founding members from a price change, and react when one takes effect.

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