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

Restore a Deleted User Account?

Discussion in 'XenForo Questions and Support' started by yavuz, Jun 3, 2011.

  1. yavuz

    yavuz Well-Known Member

    A user of mine who asked his account be deleted a year ago came to me last night and asked if his account could be restored. As far as I know, this is not possible.

    I remember when I was using SMF there was a mysql command which made deleted user accounts "undelete" or more accurate a merge solution. Is there a similar way to accomplish that with xenforo?
  2. Mike

    Mike XenForo Developer Staff Member

    While you may be able to recover some elements, the short of it is that it's really not possible.
    borbole likes this.
  3. borbole

    borbole Well-Known Member

    You can try to assign back all the posts and threads that that particular user made with these queries:

    For posts

    UPDATE xf_post SET user_id = x WHERE username ='oldusername';
    For threads

    UPDATE xf_thread SET user_id = x WHERE username ='oldusername';
    And replace x with that member new id and oldusername with their old username

    Then you might need to run the Rebuild Caches option at your acp. Hope it helps.

    You can also try to get thier old pm''s back with running a few extra queries but personally I don't have much free time to look into that now.
    Epi, DRE and yavuz like this.
  4. yavuz

    yavuz Well-Known Member

    Messages and Threads would suffice, thanks borbole.
    borbole likes this.
  5. borbole

    borbole Well-Known Member

    You are welcome :)
  6. jonsidneyb

    jonsidneyb Well-Known Member

    Did it work?
  7. Lone Wolf

    Lone Wolf Well-Known Member

    Can i use this to merge user accounts by deleting user x and assigning his posts/threads to user Y
  8. yavuz

    yavuz Well-Known Member

    Sorry getting back late, I haven't tried it back then decited not to do it.
  9. borbole

    borbole Well-Known Member

    Yes. But make first a backup of the db before you do it.
  10. DRE

    DRE Well-Known Member

    borbole likes this.
  11. D.O.A.

    D.O.A. Well-Known Member

    Can that work if I have a user who wants to be deleted, but first I want to transfer some of their threads/posts into another current user ID, that we have for such emergencies :p

    would it still be something like
    UPDATE xf_post SET user_id = x WHERE username ='person-wanting-to-be-deleted';
    so the person who wants to be deleted, their posts now go into user_id = x
    DRE likes this.
  12. DRE

    DRE Well-Known Member

    Gonna test this out right now.
  13. DRE

    DRE Well-Known Member

    It works!
    D.O.A. likes this.
  14. DRE

    DRE Well-Known Member

    This also works even if the member isn't deleted.
    D.O.A. likes this.
  15. DRE

    DRE Well-Known Member

    lol Accidentally deleted the other admin on my site. Oh man...

    I feel like... Kier needs to make it so that 'delete user' is only available on one page and one page only.

    I've never had this problem on vBulletin.
  16. rtr2006

    rtr2006 Member

    I'm pretty ecstatic about the two queries here, the threads and posts. Thank you all very much for that.

    Just wondering if it's possibly to restore likes, using a technique such as this?
  17. clove28

    clove28 Active Member

    May I know which part do I have to change other than the "oldusername" ?
  18. borbole

    borbole Well-Known Member

    You should change the user_id part as well.
  19. Mr Lucky

    Mr Lucky Well-Known Member

    Wouldn't the easiest thing be to merely change the user name to something like ex-user123. Remove all personal details from the profile. If you then change the password and email, that will then to all intents and purposes no longer be the original user. You would have the choice of keeping all posts in place, deleting them or moving to an admin only storage bin forum.
    D.O.A. likes this.
  20. Martok

    Martok Well-Known Member

    That's basically what I do if a user wants their account deleted, I no longer actually delete accounts.

Share This Page