WordPress – How to Delete Users With SQL Queries

If you want to remove WordPress user(s) and all their data here are SQL queries you should run over your database (just replace %USERS IDs% with ids of users need to be deleted.

-- Deletes any comments from specific user(s)
DELETE FROM wp_comments WHERE user_id IN (%USERS IDs%);

-- Deletes post meta for specific user(s)
DELETE t1 FROM wp_postmeta t1
LEFT JOIN wp_posts t2 ON t1. post_id = t2.ID
WHERE post_author  IN (%USERS IDs%);

-- Deletes posts for specific user(s)
DELETE FROM wp_posts WHERE post_author IN (%USERS IDs%);

-- Deletes the users account meta
DELETE FROM wp_usermeta WHERE user_id IN (%USERS IDs%);

-- Deletes the users account
DELETE FROM wp_users WHERE ID IN (%USERS IDs%);

 

Share This Post

Recent Articles

Leave a Reply

 
© 2014 LoneShooter.com. All rights reserved. Site Admin · Entries RSS · Comments RSS
· Designed by Lone Shooter