======================================
Please before you use any of this information
wait for someone to confirm that what i wrote
is correct. This is from what i just tested and
i won´t make any assurances that this always
works that way and does not screw up your website.
======================================I was about to submit this to the faq but it screws up my text badly and after using preview it´s just a big mumbo of text no one would want to edit anymore. (Marcan will this change in the future?)
So i just post it here ... and maybe someone can move it over after it has been confirmed to be correct. (or not and in that case being dumped)
(How) Can i restore a deleted user account?Why would you want to restore a user account?There are many reasons:
- a user deleted his own account and now wants it back
- sometimes even you deleted a user account and hit the wrong one
- the user might have sent you some money to get it back =)
Well there are many reasons why you might want to restore a user account back sometimes.
Now while the user could just reregister this is mostly unwanted because that would mean he will loose all old comments, forum posts and stuff. Those would be shown as "Anonymous".[/i]
Maybe even more importantly is the question:
Can you restore a user account?The good thing is:
Yes you canThe bad thing: It requires some work and fiddling around just a little with the database. And you should have a backup of your database from a point in time when the user still existed. (you can even restore users without a backup but i will get to that later)
ok, ok ... but now tell what to do ...
How can you restore a user account:Remember: Always make a backup before messing with your database!1. open your database backup ´xyz.sql´ in an editor.
2. search for the username and locate the line that looks like this one just with the username you need
INSERT INTO xoops_users VALUES (2, ´User Name1´, ´user1´, ´mail@nothing.com´, ´´, ´blank.gif´, 1105985187, ´´, ´´, ´´, 0, ´´, ´´, ´´, ´´, ´24c9e15e52afc47c225b757e7bee1f9d´, 0, 0, 0, 1, ´´, ´0.0´, 0, ´nest´, 0, 1, 0, ´´, ´´, ´´, 0);
3. Open your database tool (usually phpMyAdmin) and get into the tab "SQL"
4. Copy the line from step 2 into the textbox and execute the command
Now the user should be able to login again with his old account.
How can you restore a user account without a backup?:Remember: Always make a backup before messing with your database!This is a little more difficult because you have to find the correct user pid. To do this you could look for a forum posting by the user (now shown as anonymous) and locate some text in there to find this again in the database.
1. Have the user in question register a new account
2. Do a backup of your database
3. Locate a forum posting of the user in question and copy a unique part of the text
4. open your database backup ´xyz.sql´ from step 2 in an editor.
5. Search for the textpart you copied in step 3. Once you found it you should be in a line that looks like
INSERT INTO xoops_bb_posts_text VALUES (1, ´Text from the users posting.´);
The first value in this line (here: 1) is the pid of the user who wrote it.
6. Now head for the user data in your sql dump (lines starting with
INSERT INTO xoops_users VALUES (x,. "x" is a number and again the pid. Make sure that none of those lines contains the pid you just found in the line with the forum text.
7. Once you are sure you got the right number you can now use phpMyAdmin to browse your database. Look for the table xoops_users and browse it to the position where the new registered account is found.
8. Edit this entry and change the value of the actual pid to the one you got in step 5 and confirmed to be correct in step 6.
That should do it.
Why does this work? And is it dangerous?Well depending on your level of experience meddling in the database is always a little risky isn´t it?
My belive that this works is based on my test and on the assumption that XOOPS does not reuse pid numbers (as far as i could see) that were used once before. I am not sure where it does store this information however as the entry for in the "xoops_users" table gets deleted. My best guess would be this is stored in "xoops_groups_users_link" as that table even keeps the entries for deleted group assignments.