Skip to main content

Suppress the Set-Password Email for a Role or a Provisioning Flow

Premium Beginner

Benecaster sends a single-use password-reset email to anyone whose WordPress account was created for them rather than by them — an admin bulk enrollment, a subscriber added by hand, or the donation-completion webhook. Nobody was at a keyboard to choose a password on those flows, so without the email the subscriber can receive their feed but never log in to the account page or the billing portal.

The escape hatch is for sites whose own onboarding already sends an account-setup email. Two set-password emails means two single-use reset links, and the later one invalidates the earlier, so whichever the subscriber opens first fails with an expired link.

It also helps with large imports. A 400-address bulk import sends 400 set-password emails on top of 400 welcome emails, and a site that onboards those people another way may not want the second batch at all. The fourth argument, $source, is bulk_enroll, manual_add, donation_signup or migration, so you can suppress one flow and leave the others alone.

This filter covers provisioned accounts only, despite its name. Self-service signups — [benecaster_subscribe] and [benecaster_follower_signup] — collect the subscriber’s own password on the form, so there is no set-password link to send and the filter never runs for them. If you are trying to change what a self-service signup receives, this is the wrong hook.

If you suppress this, you must provide a password path yourself — otherwise the subscriber is stranded with a working feed and no account access, and the symptom arrives later as a support request that looks unrelated to signup.

Which of the two recipes you want: use this one when something outside Benecaster already sends the account-setup email — your own onboarding sequence, a concierge plugin, a CRM — and the built-in one is simply a duplicate. Use Replace the built-in set-your-password email with your own when nothing else is sending one and you want to send it yourself, in the podcaster’s voice. Both start by returning false here; that recipe carries on and sends the replacement.

Code

<?php
add_filter(
    'benecaster_subscribe_send_password_email',
    function ( bool $should_send, int $user_id, int $show_id, string $source ): bool {
        // Suppress for members of "founding_supporter" — that role's
        // onboarding is handled by our concierge plugin, and a duplicate
        // reset link would confuse subscribers.
        $user = get_userdata( $user_id );
        if ( $user && in_array( 'founding_supporter', (array) $user->roles, true ) ) {
            return false;
        }

        // Or suppress per flow. A bulk import of 400 addresses sends 400
        // reset emails on top of 400 welcome emails; a site that onboards
        // those people by hand may not want the second wave at all.
        if ( 'bulk_enroll' === $source ) {
            return false;
        }

        return $should_send;
    },
    10,
    4
);

View on GitHub →

Hooks Used

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