Querying for deleted users / execute code on user deletion

Topics: Core, General, Troubleshooting, Writing modules
Sep 5, 2012 at 1:28 PM
Edited Sep 5, 2012 at 1:46 PM

When you delete a user, the UserPart record remains.

Is it possible to get such a deleted record using Linq or if needed HQL?

We want to link (non-part) records to a user id, but we have to make sure that we can always get some information, even for removed users.

If we're able to get records for delete user parts, that would do just fine for us.

Edit:

In addition we'd like to know what we need to do to handle user deletion.

We'd like to execute some code whenever a user is delete, and I don't see such a callback @ IUserEventHandler

Sep 5, 2012 at 4:14 PM

I don't think there is a handler for deleting users. Probably should have, although not particularly common. You can overwrite the view and send it to your own controller that does what the AdminController in Orchard.Users does and whatever you need to do, that is what I had to do. You can also create a interface that implements IUserEventHandler and call IUserEventHandler from your delete method as is done in Orchard.Users admin controller.

Maybe there is a better way, but this worked for me. 

Sep 5, 2012 at 5:26 PM

You might also find discussion 361664 has some helpful pointers for you.