If you’re using S2Member, you know how congested your database can get with free users who never come back to the site. I was doing some client work that had this problem and came across a few forum posts, though nothing seemed to have the answer.
Instead I ended up building this free WordPress plugin: S2Member Cleaner.
This plugin is simple, lightweight, and free. It basically gives you the option to delete those “expired” users. To be considered expired, the user account must:
- Be “subscriber” level
- Been created at least 6 months prior
- Have a “last logged in” date of at least 6 months prior
The function that ends up handling this is pretty simple, and you could make your own plugin around it. Here’s the code you could use now if you wanted to delete these old free users from S2Member:
You can’t just stick that in your functions.php because it won’t do anything until you call it. Instead it’s better to wrap that in a function you can with the click of a button or on a regularly scheduled basis. That’s what this plugin does.
The plugin lets you manually delete a batch of users (we max out at 50 per batch to keep things light) or schedule it to delete on a regular basis (daily, twice daily, hourly).
Learn more about it and get the plugin here.