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?

Russ Back
  • 1,503
  • 13
  • 26

1 Answers1

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.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143