Log admin-initiated revocations to an external audit service
Access gets taken away for all sorts of reasons: a subscription lapses, a bridge syncs, some custom code tidies up. Most of those are routine. A person deciding to revoke somebody is not — it is a deliberate act, usually with a reason behind it, and it is the kind of thing an audit trail exists to record.
benecaster_subscriber_access_revoked fires only for that case: a human clicking revoke in the admin. Use it to write to a compliance log, a CRM timeline, or anywhere you need to tell deliberate decisions apart from automated churn.
Notes
Do not confuse it with benecaster_token_revoked. That one fires for every revocation whatever the cause — a lapsed subscription, an admin action, your own code. It is the right hook for cleanup that must happen no matter why access ended. This one is the right hook when only a human decision should trigger your callback.
Subscriber account is preserved: The subscriber’s WordPress user account and membership plugin record are not touched. Only the Benecaster token is revoked. If the admin intends a permanent ban, additional steps (removing the membership plugin record, blocking the user) must be taken separately.
Related Hooks
-
benecaster_subscriber_access_revoked— the hook this recipe uses; full parameter reference -
benecaster_token_revoked— fires for all revocations regardless of cause -
benecaster_subscriber_tier_overridden— companion hook for admin-initiated tier changes
Code
<?php
add_action(
'benecaster_subscriber_access_revoked',
function ( int $user_id, int $show_id ): void {
$user = get_userdata( $user_id );
my_audit_log_write( [
'event' => 'subscriber_access_revoked',
'actor' => 'admin',
'email' => $user ? $user->user_email : "user:{$user_id}",
'show_id' => $show_id,
'at' => gmdate( 'Y-m-d\TH:i:s\Z' ),
] );
},
10,
2
);
Hooks Used
Need this built rather than just documented? See our services →