Skip to main content

benecaster_token_reset_send_email

Action Free Since v1.0.0

Fires when an admin selects “Reset and send email” from the token reset dialog in the subscriber detail panel. The new token is already active and written to the database when this hook fires. Hook this action to dispatch a token reset notification — the `$new_token` parameter is the full plaintext token, available so you can embed the subscriber’s complete new feed URL in the email body.

The built-in email system hooks this action at priority 10 to dispatch the standard token reset email. To suppress the built-in email and send a fully custom version, use the `benecaster_email_should_send_token_reset` filter rather than unhooking this action — that approach is safer and works correctly alongside third-party email plugins. Free — registered regardless of license status.

Parameters

Name Type Default Description
$token_id int ID of the token record
$user_id int WordPress user ID
$show_id int ID of the show
$new_token string The full plaintext new token — available for embedding in the email; never log or store this value
$custom_message string Optional admin-supplied message; empty string when no message was provided

Examples

Log reset event, never log token

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 );
    if ( ! $user ) {
        return;
    }

    // Log the event — never log $new_token itself.
    error_log( sprintf(
        'Token reset for user %d on show %d — email dispatched.',
        $user_id, $show_id
    ) );
}, 10, 5 );

Notes

Security: $new_token is the full plaintext token. Use it only to build the email body. Never log, store, or transmit it to any system other than the email itself. Free: registered regardless of license status.