Delete User

5.40K viewsWordPressdelete meta remove user
0

Hello,
I have a question about the suppression of a user.
I have a user who created questions, I would have deleted this user, the questions and their answers are deleted.
How can I transfer all meta from one User to another (questions, reponses…), for example “Anonymous”.
Is it possible ? do you have a official plugin for this?
Thank you in advance,
Best regards.

Answered question
0

thank you for your response.
I made the necessary for the post type “answer”, “question” as well as the user_meta with the function “add_user_meta” on one side and “delete_user_meta” on the other.
Do you have any other type of page to be exchanged between users for a migration of the total datas ?
Best Regards

Answered question
0

Hello,
There is not any plugin for that. But you can do it by simply running a post query loop. Here is an example for question post type.

$the_query = new WP_Query( array(
    'post_type' => 'question',
    'author' => 0,
    'posts_per_page' => -1,
) );
 while( $the_query->have_posts() ) {
    $the_query->the_post();
    wp_update_post( array(
        'ID' => get_the_ID(),
        'post_author' => NEW_USER_ID_HERE,
    ));
}


You can do same for answers. And use comment query for comments.

Answered question