benecaster_avatar_deleted
Fires when a subscriber removes their uploaded avatar through the subscriber account page. At the point this action fires, the `_benecaster_avatar_attachment_id` user meta has been cleared and the attachment has been deleted from the WordPress media library.
This hook does not fire on idempotent deletes — if the subscriber has no avatar at the time of the delete request, the action is skipped entirely. Pair with [benecaster_avatar_uploaded](/hooks/benecaster_avatar_uploaded/) for symmetric upload and remove handling, such as invalidating a cached avatar URL whenever either event occurs.
Examples
Invalidate avatar cache on removal
add_action( 'benecaster_avatar_deleted', function ( int $user_id, int $attachment_id ): void {
// Invalidate cached avatar URL
delete_transient( 'my_avatar_url_' . $user_id );
// Log removal for audit purposes
my_audit_log( 'avatar_removed', [ 'user_id' => $user_id ] );
}, 10, 2 );