In WordPress, when you delete a user, by default you’re prompted to either delete all their content (posts, pages, comments) or attribute that content to another user. If you want to delete a user without deleting their posts and comments, you need to assign their content to another user during the deletion process.
Step-by-Step: Delete a User Without Losing Their Posts and Comments
-
Go to WordPress Admin Dashboard → Users → All Users.
-
Find the user you want to delete and click Delete under their username.
-
WordPress will show you a confirmation screen:
-
Delete all content – this deletes posts, pages, and comments created by the user.
-
Attribute all content to: – this lets you select another user to reassign all posts and comments.
-
-
Select the Attribute all content to: option and choose the user you want to assign their posts/comments to.
-
Click Confirm Deletion.
This way, the posts and comments remain on your site, just assigned to a different user.
Important Notes
-
If you don’t assign the content to another user, WordPress will delete all their posts and comments permanently.
-
Comments are assigned to the user linked to the post, so reassigning posts also keeps comments intact.
-
You can create a generic user like “Former Author” or “Guest Author” to assign content from deleted users to keep things organized.
Programmatic Way (Using Code)
If you want to delete a user programmatically but keep their posts and comments intact, you can do something like this in a plugin or theme function:
FAQs
Can I delete a user in WordPress without deleting their posts and comments?
Yes. When deleting a user from the WordPress admin, you can choose to attribute all their posts and comments to another user instead of deleting the content.
What happens if I delete a user without reassigning their posts?
All posts, pages, and comments authored by that user will be permanently deleted along with the user account.
How do I reassign a user’s posts and comments during deletion?
In the WordPress admin under Users → All Users, click Delete on the target user. On the confirmation screen, select “Attribute all content to:” and choose an existing user to reassign the content.
Is there a way to automate this process programmatically?
Yes, you can use custom code or plugins to reassign posts before deleting a user programmatically, ensuring content isn’t lost.
Should I create a generic user to assign deleted users’ content?
It’s a good practice to create a generic user like “Former Author” or “Guest Author” to assign posts from deleted users for better content management.
Deleting a user in WordPress without losing their valuable content is straightforward when you properly reassign their posts and comments to another user. Whether you use the built-in WordPress admin interface or implement a programmatic solution, ensuring content is attributed correctly helps maintain your site’s integrity and prevents accidental data loss. By following these best practices, you can manage user accounts efficiently while preserving your site’s content and user engagement.