Do you think we should be deleting registrations for a given user if their account is deleted? I was surprised to see that this isn't implemented. Were there specific reasons why?

CommentFileSizeAuthor
#1 user-cancel-1546286-1.patch4.97 KBdpi

Comments

dpi’s picture

StatusFileSize
new4.97 KB

Registration doesn't make a choice about whether content should be deleted, admins do. But your right, content should be deleted if admins make that decision.

Patch implements this, with tests.

mstef’s picture

Hey thanks - nice work. Just saved me some time.. I figured I'd be writing this one..

Why are you mentioning content, rather than users? And why do you think we should keep the registration but set the UID to either NULL or 0? How is that better than deleting the registration?

dpi’s picture

Its up for debate. If a user is deleted and it did not author a registration, but is rather associated as user_uid. Should the registration be deleted?

I mentioned content because all content (entities owned by the user) are dealt with at once by the admin when they cancel an account. But for Registration, content = registrations.

mstef’s picture

Right.. there definitely are a few ways to go, I suppose..

Perhaps the best would be an admin setting, sort of like how there is when you cancel an account, asking you what you want to do with the user's registrations?

levelos’s picture

Status: Active » Fixed

Thanks @dpi, looks good and committed.

zulfierken’s picture

I am trying to delete registrations programmatically. I tried to use I registration_user_delete but this does not do what I want.
I need to get registration id and delete registration by id. Because this code deletes all registrations added by author. I mean if I added registrations for A person and added registration for myself also; and run your code, it will delete both registration A and my registration.

I used

if (isset($registration_id)) {
db_delete('registration')
->condition('registration_id', $registration_id)
->execute();
}
to delete by registration id. There should be another registration load function to load by entity id, entity type and user id

dpi’s picture

Please post a new issue in the future. It is obvious this function deletes a users registrations, it is also a core hook: hook_user_delete.

You should use entity_delete.

Status: Fixed » Closed (fixed)

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

  • levelos committed 280dd51 on 7.x-1.x, panels, any-entity, slots, integrations, hold_state authored by dpi
    #1546286 by dpi: Delete or anonymize registrations on hook_user_cancel...