• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Changing userid of posts

#1
I had to merge two boards, but one of the users ended up with the ID of 0 since I had to delete the account. Could anyone help me with a SQL query or something to change the userid on all the posts with the userid of "0"?

For example these posts need to be changed to the userid of "1":
 

Brogan

XenForo moderator
Staff member
#2
This is a simple query:
Code:
UPDATE xf_post
SET user_id = 1
WHERE user_id = 0
However, I don't know what associated data needs to be updated.

You will likely need to rebuild post and like counts (there are queries posted for that).

You may also need to rebuild caches and the search index.

In general, I wouldn't recommend changing data by directly editing the database.
 

snoopy5

Well-known member
#3
Hi

I have a similar situation. But there are different usernames with userid of 0. Some of them even do not show up with username in the table xf_users. This is because I had several vb and photopost before and imported them into xf.

What kind of queries do I have to use to make an if-then statement? Let's say if username is=smith, then make userid=59999. For the next username , i would then use a different userid which is not yet in use.

How could I do this with phpmyadmin?
 

Jake Bunce

XenForo moderator
Staff member
#4
Hi

I have a similar situation. But there are different usernames with userid of 0. Some of them even do not show up with username in the table xf_users. This is because I had several vb and photopost before and imported them into xf.

What kind of queries do I have to use to make an if-then statement? Let's say if username is=smith, then make userid=59999. For the next username , i would then use a different userid which is not yet in use.

How could I do this with phpmyadmin?
http://xenforo.com/community/threads/after-import-some-posts-by-guest.48691/#post-522195