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

XF 1.2 Help creating a Query

Discussion in 'XenForo Questions and Support' started by Stormlilly, Feb 10, 2014.

  1. Stormlilly

    Stormlilly Member

    Hey guys,

    I would really appreciate it if one of you talented XF folks could help me out with a Query I need.

    When I used to run my forum on Vbulletin this is the SQL Query I would run to update a user's name throughout posts.

    I'm looking for something similar for XF, because the table structures are different I need a little help.
  2. oman

    oman Well-Known Member

    I believe it is much easier with XenForo.

    You should be able to edit their username within the Admin Control Panel, and then it just updates the username throughout posts automatically.

    Am I correctly following what you want to do?
  3. Chris D

    Chris D XenForo Developer Staff Member

    oman is correct in what he says. Updating the username in the Admin CP will indeed update all of the tables everywhere, but not within post content.

    So if I'm understanding the original query correctly you are looking for a way to update mentions of the old username to the new username. This would presumably be useful for updating posts which have quoted the user, etc.

    If that is the case then the query to run isn't too dissimilar.

    UPDATE `xf_post`
    SET `message` = REPLACE(`message`, 'membername1', 'membername2')
    Stormlilly and oman like this.
  4. Stormlilly

    Stormlilly Member

    Hey Oman,

    Thank you for replying.

    Do you know if it changes the instance of the username when it has been quoted by other users in conversations?

    I have updated the username manually, I just presumed that it wouldn't include changing it in post text..
  5. Stormlilly

    Stormlilly Member

    Thanks Chris! This is exactly what I am looking for
  6. oman

    oman Well-Known Member

    Not sure. Never specifically have tried it before. @Brogan might be able to confirm for you.
  7. Stormlilly

    Stormlilly Member

    All good thanks Oman :)

    The query Chris shared worked like a charm. Thank you.

Share This Page