Reputation: 79826
ive got a forum and i allow user to delete their account.
and i want the users threads to still be there and the username to be shown, but i wonder one thing.
if a user is deleted (basically i just NULL their username and password in the table row but i leave everything else intact) and another user is registering the same username, then people will believe that the new user with the same username has created all the threads the previous user created.
or is it routine to not allow new users to pick those usernames who have been deleted?
what is best practice regarding deleting users?
Upvotes: 4
Views: 1857
Reputation: 1790
You can even add an extra column in users table titled "uid" and generate new uid for every new user who registers.
Upvotes: 1
Reputation: 1531
If you keep the posts and the usernames you don't want to people to register the same username again. It will cause a lot of confusion. Typically you also make the username a unique key of the user table.
I would recommend letting the users delete their accounts completely if there are no associated posts or other activity. If there are associated posts the account is disabled and the posts marked as made by "Deleted user".
Then make it an administrative action to wipe the account and associated posts completely. This can be added to your regular maintenance tools.
Upvotes: 1
Reputation: 1724
If it's important to enable others to use the old username, you could change user's name into eg. Deleted User X - that way there would still be a connection between the user's posts (which could be important in some cases).
Upvotes: 1
Reputation: 28894
The posts should be linked to user via an ID not by username so unless you reuse an ID, which you shouldn't, then you won't have this problem.
Upvotes: 0
Reputation: 191058
I would keep a deleted
field in the table as a boolean. Set it to true when the user leaves. Keep usernames unique.
Upvotes: 3
Reputation: 33551
You should not actually delete users, just set a "deleted" flag on their records in database. If such flag is set, do not allow the user to log in. Also, show the user page with "user is deleted" on it. If you actually delete a record, you will have to decide, what to do with
So, this would actually change the conversations people have had.
Upvotes: 1
Reputation: 27102
Add an extra column to your users table, called 'deleted' or similar. Default this to zero (false). When the user is "deleted", set this field to 1 (true). That way you won't run across any problems with users having duplicate usernames, as the original will be still present and linked to your existing posts etc.
Upvotes: 11
Reputation: 171579
Add a DeletedDate column. If this column is NULL, then the user account is not deleted.
This way you are not deleting any data, and you can undelete the account later if you wish, with username, etc. intact.
Upvotes: 2