I'm deleting WP users with wp_delete_user(). It works well. I noticed when I manually delete a user in the WP Admin it asks first to "Delete all content" or "Attribute all content to: ".

I want to delete all content associated with the user. We're running some plugins that seem to have a bunch of user meta data in wp_postmeta I think. I'm assuming this is what its referring too.

Anyway, I need to make sure wp_delete_user() is, in fact, actually removing all user content too and not leaving it in there. Can anyone confirm this? Does wp_delete_user() delete all user content as if I selected "Delete all content" in the WP admin manually?



Check the docs.

wp_delete_user( $id, $reassign );

If the $reassign parameter is not assigned to a User ID, then all posts will be deleted of that user. The action 'delete_user' that is passed the User ID being deleted will be run after the posts are either reassigned or deleted. The user meta will also be deleted that are for that User ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.