Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete user best practice?

Tags:

php

mysql

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?

like image 618
ajsie Avatar asked Dec 02 '22 06:12

ajsie


2 Answers

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.

like image 143
richsage Avatar answered Dec 04 '22 12:12

richsage


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

like image 21
Daniel A. White Avatar answered Dec 04 '22 13:12

Daniel A. White