4

So I have a user group containing a few thousand users and I want to remove all of those users with a SQL script.

These users don't have access to the control panel and so don't have any Entries authored by them.

At the moment I have this:

DELETE FROM elements WHERE id IN (SELECT userId FROM usergroups_users WHERE `groupId` = 5);

It looks like this removes related entries from the users, usergroups_users and content tables by virtue of the foreign key/cascade constraints.

Is there anything else I need to clean up?

1 Answer 1

2

You've done it the correct way. Assuming all of Craft's foreign keys and cascading deletes are all still in place, removing the user's element ID from the craft_elements table is the way to go and all related data will cascade delete from there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.