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...

CommentFileSizeAuthor
#1 flag_user_delete-1223380-1.patch752 bytesgeerlingguy

Comments

geerlingguy’s picture

Status: Active » Needs review
StatusFileSize
new752 bytes

Attached 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 :-)

quicksketch’s picture

Status: Needs review » Fixed

Excellent thanks geerlingguy. Committed as-is. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.