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:
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
- Replace OldUsername with the deleted user's name.
- Replace NewUsername and NEW_USER_ID with the new user's details.
- Make sure to back up your database before running the script!