benecaster_subscribe_user_created
do_action( 'benecaster_subscribe_user_created', int $user_id, string $email )
Fires when a logged-out visitor completes the [benecaster_subscribe] shortcode and a new WordPress user account is created for them. Ships in feature/membership-signup-checkout.
Parameters
| Parameter | Type | Description |
|---|---|---|
$user_id |
int |
WordPress user ID of the newly created account |
$email |
string |
Email address used to create the account (same as the user’s user_email) |
When It Fires
SubscribeController fires this action immediately after wp_create_user() succeeds for a guest signup — before:
- The subscription row is written
- The feed token is generated
- The Stripe Subscription is created (paid path)
It fires only on guest signups that create a new WP account. It does not fire:
- When a logged-in subscriber signs up (no user creation needed)
- When the email matches an existing WP account (the endpoint returns
409 benecaster_login_required) - On free-tier signups where the user is already logged in
Why This Exists
SubscribeController intentionally does not send a welcome or set-password email itself — it fires this action so add-ons and theme functions can own the email template and delivery method. A new WP user created via wp_create_user() has no password set; the visitor needs to receive a password-reset link to gain login access.
Do not look up tokens or feed URLs from this hook. The action fires before the subscription row and feed token are created. For post-token work, use [benecaster_token_generated](/docs/benecaster_token_generated/).
Usage
add_action( 'benecaster_subscribe_user_created', function ( int $user_id, string $email ): void {
// Generate a one-time password-reset link and queue an email
$reset_key = get_password_reset_key( get_userdata( $user_id ) );
if ( is_wp_error( $reset_key ) ) {
return;
}
$reset_url = network_site_url(
"wp-login.php?action=rp&key={$reset_key}&login=" . rawurlencode( get_userdata( $user_id )->user_login ),
'login'
);
wp_mail(
$email,
'Welcome — set your password',
"Set your password: {$reset_url}"
);
}, 10, 2 );