I am using buddypress with wordpress.I accidentally deleted a user directly in data base table wp_users. Therefore just the user only deleted but the posts posted by him remains in the site. How to delete all the posts related to that deleted user. Is there any way?
1 Answer
Do it carefully this is the Query to detect all the posts from the deleted user to confirm that, the select query show you the post of the user that are not found in wp_users table.
SELECT *
FROM `wp_posts`
WHERE `post_author` NOT
IN (
SELECT id
FROM `wp_users`
)
And this is hows you run the delete query.
DELETE
FROM `wp_posts`
WHERE `post_author` NOT
IN (
SELECT id
FROM `wp_users`
)
wp_usersandposts