Skip to main content

Hook a subscriber’s buy-up purchase/cancellation to grant extra benefits or send an email

Free Beginner Since v1.0.0

BuyupsAccountController fires benecaster_buyup_purchased( int $user_id, int $buyup_id, int $show_id, string $stripe_subscription_item_id ) after a successful Stripe subscriptionItems.create and a successful insert into wp_benecaster_subscriber_buyups. benecaster_buyup_cancelled fires when a subscriber clicks Remove (cancel-at-period-end is set but the grant remains active until the period elapses). Use these instead of polling the table — the action firing order guarantees the row is persisted and the access check will immediately return true.

Code

<?php
add_action( 'benecaster_buyup_purchased', function ( int $user_id, int $buyup_id, int $show_id, string $item_id ): void {
    // Send the subscriber a transcript bundle link via a separate email.
    my_addon_send_transcript_welcome( $user_id, $buyup_id );
}, 10, 4 );

View on GitHub →

Hooks Used