Skip to main content

benecaster_subscribe_user_created

Action Free Since v1.0.0

Fires when a logged-out visitor completes the [benecaster_subscribe] shortcode and a new WordPress user account is created for them. 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, or 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, when the email matches an existing WP account (the endpoint returns 409 benecaster_login_required), or on free-tier signups where the user is already logged in.

Core now sends the set-password email itself, as of 1.42.0. This entry previously said it deliberately did not, and that listening here was how you provided one. That is no longer true and the DIY approach is no longer neededSubscribeGuestPasswordListener hooks this action and dispatches the guest_password_set managed email type by default.

To suppress it — because a role-specific onboarding flow already covers the case — return false from benecaster_subscribe_send_password_email. ⚠ That filter gates only the email. This action still fires either way, so listeners doing non-email work are unaffected by it.

A new WP user created via wp_create_user() has no password set, so the visitor needs a reset link to gain login access at all — which is why the default changed.

Do not look up tokens or feed URLs from this hook — the token does not exist yet. Use benecaster_token_generated for post-token work.

Parameters

Name Type Default 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)
$show_id int ID of the show being subscribed to. **Added in 1.42.0** — the signature widened from two arguments to three. WordPress dispatches hook arguments variadically, so **existing 2-argument listeners keep working unchanged** and need no edit.

Examples

Enrol the new account in an onboarding sequence

add_action( 'benecaster_subscribe_user_created', function ( int $user_id, string $email, int $show_id ): void {
    // Core already sends the set-password email. Use this hook for
    // work core does not do — CRM enrolment, tagging, analytics.
    my_crm()->subscribe( $email, [
        'list'    => 'podcast-onboarding',
        'show'    => get_the_title( $show_id ),
        'user_id' => $user_id,
    ] );
}, 10, 3 );

Notes

Do not add your own set-password email here. Core sends one by default as of 1.42.0, so a listener that sends another produces two emails with two different single-use reset links — and the second link silently invalidates the first, so a subscriber who clicks the earlier email gets an expired-link error. If you want your own copy instead of ours, suppress the core one with benecaster_subscribe_send_password_email first.

This hook fires before the subscription row, the feed token, and the Stripe subscription exist. Anything that needs those belongs on a later hook.