Good way to auto delete old unverified and spam accounts?
-
So i’m looking for a good way to auto delete spam accounts. Long story short, I found this:
`function spammersdeletion() {
global $wpdb;
$from = strtotime(‘-30 day’, time());
$wpdb->query(‘DELETE FROM wp_users WHERE DATE(user_registered) < "'.date('Y-m-d', $from).'"AND user_status = "2"');
}add_action(‘init’,’spammersdeletion’);`
Source:http://stackoverflow.com/questions/6212636/how-to-delete-unverified-users-in-buddypressIs this ok to do? I remember reading somewhere that you shouldn’t directly query to wordpress database. I also took a look at the wp_users database in phpMyAdmin, and I noticed a list of user_id values with 1, all those accounts being accounts I marked as spammers from buddypress frontend. If the above function is ok, can I create another function to handle user_id = 1? I’m just a bit scared of writing a function that deletes legitimate accounts…
- The topic ‘Good way to auto delete old unverified and spam accounts?’ is closed to new replies.