benecaster_token_generated
Fires after a new subscriber token is created and persisted to the database. The token is fully active at this point. Use this hook when you need the token record’s database ID — for example, to associate the token with a record in an external system, trigger a welcome sequence, or log the new subscriber event.
This hook fires as part of the subscription activation flow, and fires again if a token is ever reset — a reset creates a new token record with a new ID. It does not fire when an existing token’s tier is updated, since tier changes update the existing record in place. If you only need to react to a new subscriber and do not require the token ID, use [benecaster_subscription_activated](/hooks/benecaster_subscription_activated/) instead.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$token_id |
int |
— | ID of the new token record |
$user_id |
int |
— | WordPress user ID |
$show_id |
int |
— | ID of the show |
$tier_slug |
string |
— | Tier slug for this subscription |
Examples
Register subscriber in onboarding system
add_action( 'benecaster_token_generated', function( int $token_id, int $user_id, int $show_id, string $tier_slug ) {
$user = get_userdata( $user_id );
my_onboarding_system_create_record( [
'token_id' => $token_id,
'email' => $user->user_email,
'show_id' => $show_id,
'tier' => $tier_slug,
'created_at' => current_time( 'mysql' ),
] );
}, 10, 4 );
Notes
This is a Premium hook — it is only registered when a valid license is active. In multi-show setups with high subscriber volume this hook can fire frequently. Keep callbacks lightweight or dispatch background jobs for any non-trivial work.