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"?

surefyre
 
hutman replied on at Permalink Reply
hutman
It looks like this featured hasn't made it into 5.7 or 5.8 yet, it used to exist in 5.6.

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.
surefyre replied on at Permalink Reply
surefyre
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.
katz515 replied on at Permalink Reply
katz515
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.
surefyre replied on at Permalink Reply
surefyre
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.
rtcary replied on at Permalink Reply
rtcary
Did you ever find a way to bulk delete users?

Todd
surefyre replied on at Permalink Reply
surefyre
Nope. Can't be done :o(

Hopefully it'll make it in as an (obvious) feature sometime soon
tnours replied on at Permalink Reply
tnours
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();
}
}

} ?>
JohntheFish replied on at Permalink Reply
JohntheFish
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...