Delete user best practice?

ive got a forum and I allow the user to delete their account.

and I want the user streams to still be there and the username that will be shown, but I'm interested in one thing.

if the user is deleted (basically I just NULL their username and password in the table row, but I leave everything else intact) and the other user logs the same username, then people will assume that the new user with the same username Created all threads created by the previous user.

or is it a normal procedure to prevent new users from choosing the usernames that have been deleted?

What is the best way to delete users?

+4
source share
8 answers

Add an extra column to your users table called "deleted" or similar. The default value is zero (false). When the user is "deleted", set this field to 1 (true). This way, you will not run into any problems with users having duplicate usernames, as the original will still be present and associated with your existing messages, etc.

+10
source

I would save the deleted field in the table as a boolean. Set to true when the user leaves. Keep unique usernames.

+3
source

Add a DeletedDate column. If this column is NULL, the user account is not deleted.

This way you do not delete any data, and you can restore your account later, if you want, with a username, etc. intact.

+1
source

You should not actually remove users, just set the β€œremote” flag in your database entries. If this flag is set, do not allow the user to log in. Also show the user page with "user deleted". If you really delete the entry, you will have to decide what to do with

  • forum posts the user has created.
  • user replies
  • responds when someone mentions something said by the remote user.
  • private messages sent to / from this user

So, that would actually change the conversations that people had.

+1
source

If it is important that other users use the old username, you can change the username, for example. Remote user X - this way there will be a connection between user messages (which may be important in some cases).

+1
source

If you save messages and usernames, you don’t want people to register the same username again. This will cause a lot of confusion. Typically, you also make the username a unique key to the user table.

I would recommend that users delete their accounts completely if there are no related messages or other activity. If there are related messages, the account is disabled, and messages are marked as made by the "Remote User".

Then do this as an administrative action to completely erase the account and related entries. This can be added to your regular maintenance tools.

+1
source

You can even add an extra column to the user table called "uid" and create a new uid for each new user that logs in.

+1
source

Posts should be associated with the user by identifier, but not by user name, so if you do not reuse an identifier that you do not need, then you will not have this problem.

0
source

All Articles