How do you bulk delete users?
Permalink 1 user found helpful
I daresay this isn't the right forum category but it is a problem I'm having while developing.
I have about 30 test users I want to delete to clean the installation up, Is there no way to tick them all and somehow delete them as admin?
Have seen many older posts asking this but there doesn't seem to be an answer.
Is it 'safe' to "delete from Users where xx"?
I have about 30 test users I want to delete to clean the installation up, Is there no way to tick them all and somehow delete them as admin?
Have seen many older posts asking this but there doesn't seem to be an answer.
Is it 'safe' to "delete from Users where xx"?
Surprised it doesn't exist and yes, just binning the rows from the DB is the least pleasant option :o/
Perhaps someone reading this thread will know if it's scheduled to reappear as a feature any time soon.
Perhaps someone reading this thread will know if it's scheduled to reappear as a feature any time soon.
FYI
Here is the GitHub issue.
https://github.com/concrete5/concrete5/issues/631...
As you know concrete5 is open source, there must be someone who are willing to pay or donate their time to develop its function :p
Let's wait or help work on it, please.
Here is the GitHub issue.
https://github.com/concrete5/concrete5/issues/631...
As you know concrete5 is open source, there must be someone who are willing to pay or donate their time to develop its function :p
Let's wait or help work on it, please.
It's fairly easy to bulk delete from the User table but the proper way would be to reassign stuff with deleted user IDs elsewhere in the DB to, say, admin or another designated user. That's the tricky part.
Although I suppose there must be a delete function to delete one user so repeatedly calling that in code might be the best idea.
If I find time I might build it but up to my ears in work at the moment.
Although I suppose there must be a delete function to delete one user so repeatedly calling that in code might be the best idea.
If I find time I might build it but up to my ears in work at the moment.
Did you ever find a way to bulk delete users?
Todd
Todd
Nope. Can't be done :o(
Hopefully it'll make it in as an (obvious) feature sometime soon
Hopefully it'll make it in as an (obvious) feature sometime soon
To do this in 5.7, I create an invisible page only accessible by the admin on my site. Create a new page template and insert this in the template's source...
It will delete all users except the first/main admin user.
<?php
$list = new \Concrete\Core\User\UserList();
$users = $list->getResults();
$ID = null;
$Name = null;
foreach ($users as $user) {
$ID = $user->uID;
$Name = $user->getUserName();
if ($ID != 1) {
$userInfoObject = UserInfo::getByID($ID);
if ($userInfoObject) {
$userInfoObject->delete();
}
}
} ?>
It will delete all users except the first/main admin user.
<?php
$list = new \Concrete\Core\User\UserList();
$users = $list->getResults();
$ID = null;
$Name = null;
foreach ($users as $user) {
$ID = $user->uID;
$Name = $user->getUserName();
if ($ID != 1) {
$userInfoObject = UserInfo::getByID($ID);
if ($userInfoObject) {
$userInfoObject->delete();
}
}
} ?>
My Extreme Clean addon includes a user cleaner (and many other cleaners):
https://www.concrete5.org/marketplace/addons/extreme-clean1/...
https://c5magic.co.uk/addons/extreme-clean...
https://www.concrete5.org/marketplace/addons/extreme-clean1/...
https://c5magic.co.uk/addons/extreme-clean...
You can do that query but it will leave all of the user attribute values out there and I'm not sure what ill affects that will have on your site, it could break things.