How to process records when deleting a user?

I am running a forum that I created. So, all users have the opportunity to delete themselves.

But all their topics and messages will remain. But now, when he has to say that their username is just empty.

How can I do it?

Should I create a new user and call him, for example. "remote user" and assign all threads / messages to this identifier when they delete themselves? Or should I just check if the user id exists if it doesn't print, for example. "remote user" as username?

What is the smartest way? Any other ways tell me.

Thanks!

ps (I am not a native speaker of English, I was looking for some fancy words in the online dictionary)

+4
source share
1 answer

I would suggest that I did not actually delete the user. You can simply add a column to the users table, for example:

ALTER TABLE users ADD COLUMN (is_active TINYINT(1) NOT NULL DEFAULT 1); 

Then, when you β€œdelete” the user, simply mark them as inactive:

 UPDATE users SET is_active = 0 WHERE users.id = 7; 

For user lists and account access, you should check the is_active status. To display data, such as messages and what not, you will not care about their active status, you just get the name from the table.

+7
source

All Articles