Im just noticed that when I try to delete an user does remove the user, but not their comments. Also choosing the option to change the deleted user's post author to admin does not work either. Is there an action that I could use to just write my own code to make these work?


WordPress should give this option below Attribute all posts to:

Anyhow, I wrote a post on this (Clean Comments Table After User Deleted)


Also, you can move your all posts from deleted users to admin user.

global $wpdb;
$admin_id = 1; // Assign admin user id here
$posts_table = $wpdb->prefix . 'posts';
$users_table = $wpdb->prefix . 'users';
$strQuery = "UPDATE `$posts_table` SET post_author = $admin_id WHERE post_author NOT IN (SELECT ID FROM $users_table)";
echo $strQuery;
  • I know I can do what you said. I guess my question would be is there a way to capture the option that the admin selected? – LouieV May 15 '13 at 17:52
  • Which option???? – 0_0 May 15 '13 at 18:51
  • Delete all posts. Attribute all posts to: – LouieV May 15 '13 at 19:16
  • If you want to move all posts from deleted users to another user, then you don't need to delete them, you can just use the above update query to move all posts from user to another user. make sure you pass correct ID of user which you want to move all posts from deleted users. to get user id from username, use this script – 0_0 May 15 '13 at 19:38
  • I dont think your're understanding what Im trying to do. I want to do either or, depending on what the admin chooses from the dashboard: -Delete all post. -Attribute all post to: – LouieV May 15 '13 at 19:48

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.