Send a Slack DM when an admin resets a subscriber’s token
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.
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
);