Flag module currently implements hook_user_cancel(), and when a user account is cancelled, flags for that user and flag counts for the content that user has flagged are updated. However, according to hook_user_cancel's documentation,
This hook is NOT invoked for the 'user_cancel_delete' account cancellation method. To react on this method, implement hook_user_delete() instead.
...so, in order to also allow for user account deletion (which can happen in a variety of different ways), Flag.module should also implement hook_user_delete() and do the same things it does in hook_user_cancel. I can confirm that, on my site, flags are not removed for deleted user accounts.
Patch to be posted in a few minutes...
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | flag_user_delete-1223380-1.patch | 752 bytes | geerlingguy |
Comments
Comment #1
geerlingguy commentedAttached patch moves the functionality of hook_user_cancel into flag_user_account_removal callback, and then calls that callback with the account information from both hook_user_cancel and hook_user_delete.
I've tested this patch with all four methods of user account deletion/cancellation, and it works for all of them, from both the end user's interface and the administrator's interface. Please review and commit :-)
Comment #2
quicksketchExcellent thanks geerlingguy. Committed as-is. Thanks!