Skip to main content

benecaster_token_type_changed

Action Free

Fires after a token’s token_type column is changed in place. Three transitions fire it. follower to subscriber, on any subscription activation for a user whose token for that show is a follower’s: every bridge, the built-in membership, and Subscribers → Bulk enroll as subscribers. subscriber to purchaser, when a listener who holds standalone access loses their membership. purchaser to subscriber, when a buyer subscribes. Free — it fires on the free WordPress.org product too, since follower signup and the bridges are not license-gated.

Fires from TokenManager::generate_or_reactivate()‘s promote_follower() branch, after the new type is written, and only when the row actually changed: the write is a compare-and-set guarded on the old type, so two activation events for the same person in one request fire this hook at most once. It also fires on the revoked-row branches, including a row a podcaster deliberately revoked — the type is still promoted, the row stays revoked, and a later Reset Token reinstates a subscriber rather than a follower. token_hash is never touched, so the feed URL does not change.

Not a closed set. A type an add-on registers adds more transitions — test both $old_type and $new_type rather than assuming follower/subscriber.

Parameters

Name Type Default Description
$token_id int — ID of the token record whose type changed
$user_id int — WordPress user ID
$show_id int — ID of the show
$old_type string — Token type before the change (e.g. 'follower')
$new_type string — Token type after the change (e.g. 'subscriber')

Examples

Move a converted follower between ESP/CRM lists

add_action( 'benecaster_token_type_changed', function ( int $token_id, int $user_id, int $show_id, string $old_type, string $new_type ): void {
    if ( 'follower' !== $old_type || 'subscriber' !== $new_type ) {
        return; // Other transitions are planned; react only to the one you handle.
    }

    $user = get_userdata( $user_id );
    if ( ! $user ) {
        return;
    }

    my_esp_move_contact( $user->user_email, from: "show-{$show_id}-followers", to: "show-{$show_id}-members" );
}, 10, 5 );

Notes

Nothing demotes a subscriber back to follower. A cancellation revokes the token, or, for a listener holding standalone access, converts it to purchaser; it never reverses to follower.

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