Skip to main content

Send a Slack DM when an admin resets a subscriber’s token

Premium Beginner

When an admin resets a subscriber’s token and checks “Send notification email”, this hook fires with the new plaintext token — allowing any notification channel (Slack, CRM, custom mailer) to embed the complete new feed URL. The built-in email system also hooks this action. Security note: the full token is passed once and is not retrievable after this hook fires — treat it like a password.

The built-in email system (Email Editor add-on or default templates) hooks this same action to send the standard token_reset email. Your callback can run alongside it or replace it entirely by suppressing the default via benecaster_email_should_send.

Notes

Security: $new_token is the full 64-character hex token — treat it like a password. Do not log it. Embed it in the notification and discard the variable. It is not retrievable after this hook fires.

Admin message: $custom_message is the optional note the admin typed in the reset dialog. It may be an empty string if the admin did not add a note.

Build the full feed URL using benecaster_token_url or by constructing it from the token and the show’s feed base URL. The token alone is not a usable URL.

Related Hooks

Code

<?php
add_action(
    'benecaster_token_reset_send_email',
    function ( int $token_id, int $user_id, int $show_id, string $new_token, string $custom_message ): void {
        $user     = get_userdata( $user_id );
        $feed_url = home_url( '/podcast-feed/?token=' . $new_token );

        wp_remote_post( MY_SLACK_WEBHOOK_URL, [
            'body'    => wp_json_encode( [
                'text' => sprintf(
                    'Token reset for %s. New feed URL: %s. Admin note: %s',
                    $user->user_email,
                    $feed_url,
                    $custom_message ?: '(none)'
                ),
            ] ),
            'headers' => [ 'Content-Type' => 'application/json' ],
            'timeout' => 5,
        ] );
    },
    10,
    5
);

View on GitHub →

Hooks Used

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