React to a badge definition being deleted
When a badge definition is deleted, Benecaster quietly removes the tier-auto rules and detaches manual grants — but anything outside of Benecaster doesn’t know it happened. If you’ve mirrored badge assignments into an external system (a CRM tag, a community platform role, a Slack notification, a Zapier zap), those references go stale with no signal.
benecaster_badge_definition_deleted gives you that signal. It fires after Benecaster’s own cleanup completes and passes the badge ID, its parent tier ID, and the full pre-delete badge data — label, icon, color — so you can react without needing to resurrect the row: revoke the corresponding external role, write an audit entry, notify your team, or trigger any downstream cleanup your integration requires.
Code
<?php
add_action( 'benecaster_badge_definition_deleted', function ( int $badge_id, int $tier_id, array $badge ): void {
my_audit_log( sprintf( 'Tier badge "%s" (#%d) deleted from tier %d', $badge['label'], $badge_id, $tier_id ) );
}, 10, 3 );
Hooks Used
Need this built rather than just documented? See our services →