Tutorials How to Recover Posts/Threads/Messages from a Deleted User in XenForo

XFModz

Administrator
Staff member
Admin
‎1 Year of Service‎
If you've deleted a user in XenForo and their posts or private messages are still showing up, you can reassign that content to a new user with a simple SQL script. This tutorial covers how to do that for public posts and private conversations.

Run this SQL script to update posts, threads, and profile posts for a deleted user:
Code:
UPDATE xf_post SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername'; UPDATE xf_thread SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername'; UPDATE xf_profile_post SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername'; UPDATE xf_profile_post_comment SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername';

Script for Private Messages​

To update private messages and conversations, use this script:
Code:
UPDATE xf_conversation_message SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername'; UPDATE xf_conversation_master SET username = 'NewUsername', user_id = NEW_USER_ID WHERE username = 'OldUsername'; UPDATE xf_conversation_recipient SET user_id = NEW_USER_ID WHERE user_id = (SELECT user_id FROM xf_user WHERE username = 'OldUsername');

How to Use​

  1. Replace OldUsername with the deleted user's name.
  2. Replace NewUsername and NEW_USER_ID with the new user's details.
  3. Make sure to back up your database before running the script!
These scripts will reassign all relevant content from the deleted user to the new user. That’s it! Quick and simple.
 
Back
Top