React to a badge definition being deleted
benecaster_badge_definition_deleted fires after a badge definition row is removed. The hook passes the badge ID, its parent tier ID, and the full pre-delete badge data — label, icon, color, and sort order — so listeners can record an audit log without needing to resurrect the row. Core’s cascade-cleanup removes tier-auto grants and detaches manual grants from the definition, leaving the subscriber’s copied label, icon, and color intact.
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 );