BB Press Users Cleanup
I finally got around to removing all the bot-users (about 3100 in total) that had registered in my BB Press Forum. Here’s what I did. It’s not for the novice, and I don’t take responsibility for anything that blows up. Of course, always backup first.
Step 1:
Installed Human Test for BB Press
Step 2:
Used AmR-Users to generate a CSV list of bot users by generating a report that excluded user levels of 0,1,2,3,4,5,6,7,8,9,10 and making the id visible.
Note – my BB Press installation is integrated with Wordpress, so they share the same users tables. This method would only work in that case, because if the user doesn’t validate their email address, then it’s not set up with a role in WordPress.
Step 3:
Used Excel to reformat the list – creating a list of all the ID’s, with a comma after.
Step 4:
I wrote a quick script to actually delete the users. The array part was 3100 lines long, just a copy and paste from Excel.
<?php
/*
Plugin Name: Bot Cleanup
Description: Get rid of BBpress bot users.
Version: 0.1
*/
function wphive_delete_now() {
$ids = array(
1856,
1857,
1234
);
if ($_REQUEST['delete'] == 'now') {
require_once(ABSPATH.'/wp-admin/includes/user.php');
foreach ($ids as $id) {
wp_delete_user( $id );
}
}
}
add_action('init', 'wphive_delete_now');
?>
Step 5:
Installed it as a plugin in WordPress and activated it. Don’t forget to uninstall it and delete it after you are done.
Step 6:
Loaded up my website with the appropriate GET to activate it:
http://domain.com/index.php?delete=now and Voila! all those spammy users disappeared. I actually had to load it twice because it timed out the first time after deleting about 2400 users.
