XF 1.3 sql command change user id

Adam Howard

Well-known member
OK. So basically X user was deleted and restored. But not 100% completely.

Old user ID is 10096
New User ID is 10485

Looking for a quick SQL command that will search all tables and replace those values correctly to associate it with the correct account.
 
PHP:
SELECTDISTINCT
TABLE_NAME
FROM
INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME ='user_id'

I know this command will tell me all the tables where user_id column is. But I would rather not have to do a search and replace on each table individually.

Sort of looking for a search all tables for column X, see if value is Y, and if so change to Z.
 
http://xenforo.com/community/threads/can-i-combine-2-accounts.23722/#post-415713

No need to search all tables. Just do posts and threads. Other records that use the user_id are deleted when you delete a user, such as PMs.
Thanks, but not what I was looking for (see post #1)

User was deleted, then using another add-on was restored, but generated a new user id number in the process. Post are oddly associations, but other aspects were not.

Orphan user id is still in database and goal is to replace orphan with current ;)
 
Thanks, but not what I was looking for (see post #1)

User was deleted, then using another add-on was restored, but generated a new user id number in the process. Post are oddly associations, but other aspects were not.

Orphan user id is still in database and goal is to replace orphan with current ;)

There is no feature to merge users. It would have to be done manually with SQL queries for each and every user_id field. It will be tedious.

I do not recommend this.
 
There is no feature to merge users. It would have to be done manually with SQL queries for each and every user_id field. It will be tedious.

I do not recommend this.
Already done. :D Took a while... o_O. But done. ;)

The user was deleted.
I then restored the user (there is an add-on for un-deleting deleted members)

Turns out it didn't restore everything and does so by making technically a new user id (same name as before though). It then tries to associate the two, but it didn't do such a hot job.

So I did it all manually.... Took a while, but done.
 
Back
Top Bottom