Rename deleted member

Alvin63

Well-known member
So I forgot to rename a members account when deleting it. They had used their real name to sign up but instead of asking me to change the username they opened another account and wanted the original one deleted.

So I deleted it but forgot to anonymise it - so his name still shows.

Anything I can do either undelete the account or change the name associated with the deleted account?
 
EDITED:

You can create a new member and get their id (eg 123 in the example below)

Then use this query where Deleted Member id the username of the deleted member

Code:
UPDATE `xf_post`
SET `user_id` = replace(user_id, '0', '123')
WHERE username = 'Deleted Member'

The account becomes restored to the new user which you can then rename (and subsequently delete if you want
 
Last edited:
You can create a new member, eg called anon. Get their id (eg 123 in the example below)

Then use this query

Code:
UPDATE `xf_post`
SET `user_id` = replace(user_id, '0', '123')
WHERE username = 'anon'

The account becomes restored to the user anon which you can then delete.

Just a minor observation, it will do what is required, but that will obviously remove the posts from all deleted users which may be more than is required here.
 
Just a minor observation, it will do what is required, but that will obviously remove the posts from all deleted users which may be more than is required here.
I'll check then I copied that from my notes, but as always you should do things with a backup close by!

EDIT: bit of a typo there, the query and instructions in post #4 should now be correct. I have tested it

Deleted User will become undeleted and take on the username of the newly created user.
No posts should be deleted
They can then be deleted again and the original name assigned to the posts is changed.

Always do a test and/or have a handy backup!
 
Last edited:
I'll check then I copied that from my notes, but as always you should do things with a backup close by!

EDIT: bit of a typo there, the query and instructions in post #4 should now be correct. I have tested it

Deleted User will become undeleted and take on the username of the newly created user.
No posts should be deleted
They can then be deleted again and the original name assigned to the posts is changed.

Always do a test and/or have a handy backup!

Yeah, I think we were both getting muddled - I had ignored your "WHERE" clause and looking back, the "WHERE" clause was wrong anyway - all looks good to me now (y)
 
EDITED:

You can create a new member and get their id (eg 123 in the example below)

Then use this query where Deleted Member id the username of the deleted member

Code:
UPDATE `xf_post`
SET `user_id` = replace(user_id, '0', '123')
WHERE username = 'Deleted Member'

The account becomes restored to the new user which you can then rename (and subsequently delete if you want
Thanks. He only had two posts under that name anyway :-)
 
Top Bottom