MyBB Community Forums

Full Version: Removing large number of inactive users
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

A colleague of mine recently tasked me with carrying out a large user prune of our mybb-based forums.

I did manage to get a large list of eligible user accounts through a manual SQL query, however, then I found out mybb lacks any sort of official or updated form of API access, so although I have the list of about 1600 users, I didn't find a way to easily remove those.

Before I start hacking together a solution on my own, would anyone here be able to give me a hint of how I might delete the ~1600 users, by their UID / Username?

Note: Running the latest version of MyBB available - 1.8.37, php 7.4 and MariaDB

Thanks for any pointers and your time.
MyBB has User Pruning functionality in its core.
Go to ACP > Configuration >Settings > User Pruning
Enable the setting and set your criteria. The system will do the rest.
Unfortunately, that functionality isn't nearly complex enough in terms of criteria for deletion that I'd need.

Have an example SQL query I've come up with that would fit my needs, to get an idea:
SELECT uid, username FROM users WHERE
postnum = 0 AND
avatartype = "" AND
(
((timeonline < (30*60)) AND (lastvisit < UNIX_TIMESTAMP(NOW() - INTERVAL 6 MONTH))) OR
((timeonline < (60*60)) AND (lastvisit < UNIX_TIMESTAMP(NOW() - INTERVAL 2 YEAR))
);

The conditions being: User has 0 posts, no avatar, has spent less than 30 minutes online and last logged in 6 months ago, or spent less than an hour online and last logged in more than 2 years ago.
I don't see anything wrong with your query; only one closing bracket missing at the end.

What error you are encountering with?
Are you considering proper table prefix for users table?
(2024-02-12, 12:38 PM)effone Wrote: [ -> ]I don't see anything wrong with your query; only one closing bracket missing at the end.

What error you are encountering with?
Are you considering proper table prefix for users table?

The query is fine, issue is how do I actually delete users it returns, as I don't presume user deletion in MyBB is a simple "DELETE FROM users WHERE uid = 1337;", but that more work needs to be done on the backend.

Or is that not the case?
Yes its simply DELETE FROM...
You are selecting the users having no post, no activity as such. There should not be any complicacy to prune them.

For a safer hand:
1. Check and select those who have not sent any private message as well.
2. May consider moving them to an additional custom table instead of deleting or keep a backup so that they can be recovered if something goes wrong.