MySQL Query to Bulk Delete Spam Wordpress Users -


my membership website has been inundated spam sign ups. 1 thing noticed lot of spammers emails @hotmail.com.

what want delete users subscribers , have @hotmail email address.

the users data in 2 tables wp_users , wp_usermeta , far understand, need delete data in both tables remove users. haven't managed find query can delete users data mysql across 2 tables.

i can delete users in wp_user table query

delete   wp_users   user_email  "%@hotmail%" 

but need delete data wp_usersmeta table , make sure deleting subscribers (meta_key = wp_capabilities , meta_value = subscriber).

any ideas how can this? there users data in other tables i'm missing? subscribers not have posts associated them.

i've seen plugins spam sign ups preventative. right now, need way rid of these annoying spammers emails.

you can use inner join when using delete in mysql.

delete  wp_users  inner join wp_usermeta on wp_users.id = wp_usermeta.user_id  wp_users.user_email  "%@hotmail%" , [etc, etc.] 

this solution gives 2 (or maybe more ;-)) problems: 1) can't reassign posts , links (if want) , 2) have deal json values in mysql.

a better way use wordpress functions job. can use get_users search users , wp_delete_user delete user.

<?php $args = array(     'blog_id'      => $globals['blog_id'],     'role'         => 'subscriber',     'search'       => '*@hotmail.com'  );  $blogusers = get_users($args);     foreach ($blogusers $user) {         wp_delete_user( $user->id, $reassign );     } ?> 

please read function reference: solve problem , future problems.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -