I'm currently building a plugin that uses a table that contains rows with an 'active' field set to 1.
If an admin deletes a user from the system, I want to change this value to 0.
I found an 'onUserDelete' event documented but can't work out where or how to use it.
Any help would be greatly appreciated!
EDIT UPDATED:
I now have this code in the init() function of my plugin controller but deleting a user does not seem to fire the code:
parent::init();
craft()->on('users.onDeleteUser', function(Event $event) {
$user = $event->params['user'];
$userId = $user->id; // ???????
$craft->memberships_membership->cancelMembershipById($userId);
});
Any ideas?