Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
592 views
in Q2A Core by
Lets suppose that I have a large list of users (about 50k users in txt or csv file) and I want to delete all of them. What is the easiest/safest way to do that?

The list may have the usernames of the 50k users.
Q2A version: 1.7

1 Answer

+2 votes
by
selected by
 
Best answer

You can create a script that bootstraps Q2A and removes the users (without the web server) using the internal user deletion function.

Something like this should work:

<?php
require_once '/path/to/q2a/qa-include/qa-base.php';
require_once QA_INCLUDE_DIR . 'app/users-edit.php';

$users = # here goes your logic to fetch the users
foreach($users as $user) {
    qa_delete_user($user['userid']);
    echo 'User deleted: ' . $user['handle'] . PHP_EOL;
}
by
+1
That's fantastic! I have not thought about this. I was thinking about creating a plugin (that is something difficult for me), but this seems much easier.
by
+2
Right. This is much simpler. You can run it from a terminal with:
php -f your-file.php

And that's it
...