Notify the Ops Channel When a Token Reactivation Is Blocked
A podcaster-triggered Remove / Revoke Access sets revocation_reason = 'admin_revoked' on the token row. If a membership plugin later fires an activation event for that subscriber — they resubscribed, or a failed payment cleared — TokenManager::generate_or_reactivate() refuses to silently resurrect the row and fires benecaster_token_reactivation_blocked instead.
Each dispatch is somebody paying and receiving nothing. Their membership is active and billing; their feed is not being served. The longer it goes unnoticed, the likelier it ends as a chargeback rather than a support question — which is why an ops ping is worth wiring even though Benecaster already publishes an admin notice.
To reinstate, use Reset Token on the subscriber’s detail panel. Re-running the activation hits the same guard.
Code
<?php
add_action(
'benecaster_token_reactivation_blocked',
function ( int $token_id, int $user_id, int $show_id, string $tier_slug, string $reason ): void {
$user = get_userdata( $user_id );
$show = get_the_title( $show_id );
if ( ! $user || '' === $show ) {
return;
}
// Non-blocking Slack POST — do not let a slow webhook stall the
// bridge activation path. `blocking => false` returns before the
// response arrives; failures are silent by design.
wp_remote_post( 'https://hooks.slack.com/services/T000/B000/XXX', [
'blocking' => false,
'timeout' => 2,
'body' => wp_json_encode( [
'text' => sprintf(
':warning: %s tried to reactivate on *%s* (%s) but their token is admin-revoked (reason: `%s`). Review in %s',
$user->user_email,
$show,
$tier_slug,
$reason,
admin_url( 'admin.php?page=benecaster-subscribers&show_id=' . $show_id )
),
] ),
] );
},
10,
5
);
Hooks Used
Need this built rather than just documented? See our services →