Jump to content

What do you think is the proper way to automatically delete users?


Go to solution Solved by imgrooot,

Recommended Posts

I currently have a php code at the top of the page that would automatically delete a user from the database if a certain condition isn't met before 24 hours. This code is processed no matter where you are on the site.

 

I have two questions.

1. Will this be an issue if the database has thousands of users?

2. Is there a better way to do this?

Link to post
Share on other sites

1. Maybe? Technical details and a precise description would make it easier to answer.

2. Maybe? Technical details and a precise description would make it easier to answer.

 

Oh. Advice: don't delete stuff. I'd give you a better alternative but technical details and-- well, you know.

Link to post
Share on other sites

1. Maybe? Technical details and a precise description would make it easier to answer.

2. Maybe? Technical details and a precise description would make it easier to answer.

 

Oh. Advice: don't delete stuff. I'd give you a better alternative but technical details and-- well, you know.

 

What technical details are you looking for?

 

I do not require you to give me a code example.  I am simply looking for alternative methods. Word description should suffice.

Link to post
Share on other sites

Looking for more than just "a user" (who? did they sign up? are they in a pending state?) "the database" (list of users? list of pending users? list of users with temporary access?) "certain condition" (pending state? failed subscription renewal? didn't follow instructions?) "site" (what kind of site?) "has thousands of users" (logical users stored in the database? actual users who connect? concurrent?) and "better way to do this" (what is the purpose? does it meet your needs right now? asking about best practices?)

 

Believe it or not, in the software industry, a question can have multiple correct answers that depend on circumstances. And I, for one, am not going to rack my brain for all the answers I can think of only to discover none of them are actually relevant to you.

 

Or maybe you want the tldr version?

Link to post
Share on other sites

The whole approach sounds odd.

 

The standard workflow for user management looks more like this:

  • When the user account is initially created, you store the timestamp and set an “activated” flag to “false”.
  • Within a certain timeframe (in your case 24 hours), the user can activate their account, i. e. set the flag to “true”.
  • As long as the account isn't activated, the user only has limited permissions (or no permissions at all, whatever is appropriate).
  • If you absolutely must clean up dead accounts, you can set up a cron job which does this regularly. But as requinix already said, deleting data is rarely a good idea. Nowadays, a few extra bytes of MySQL records really don't hurt your HDD/SSD, and you never know when that data might be useful (debugging, statistics, ...). Get rid of sensitive information, though.
Link to post
Share on other sites
  • Solution

 

The whole approach sounds odd.

 

The standard workflow for user management looks more like this:

  • When the user account is initially created, you store the timestamp and set an “activated” flag to “false”.
  • Within a certain timeframe (in your case 24 hours), the user can activate their account, i. e. set the flag to “true”.
  • As long as the account isn't activated, the user only has limited permissions (or no permissions at all, whatever is appropriate).
  • If you absolutely must clean up dead accounts, you can set up a cron job which does this regularly. But as requinix already said, deleting data is rarely a good idea. Nowadays, a few extra bytes of MySQL records really don't hurt your HDD/SSD, and you never know when that data might be useful (debugging, statistics, ...). Get rid of sensitive information, though.

 

 

I understand the normal process of registering user and sending them an email link to activate their account.  Unfortunately my process has to be little different. The user is activated with the signup. So no activation email link is required. They have 24 hours to make a payment or else their account is deleted. I'll take your advice to keep their essential data(user's primary info) and delete all other data.

 

I have never used cron job before but it seems to be exactly what I am looking for.

Link to post
Share on other sites

Looking for more than just "a user" (who? did they sign up? are they in a pending state?) "the database" (list of users? list of pending users? list of users with temporary access?) "certain condition" (pending state? failed subscription renewal? didn't follow instructions?) "site" (what kind of site?) "has thousands of users" (logical users stored in the database? actual users who connect? concurrent?) and "better way to do this" (what is the purpose? does it meet your needs right now? asking about best practices?)

 

Believe it or not, in the software industry, a question can have multiple correct answers that depend on circumstances. And I, for one, am not going to rack my brain for all the answers I can think of only to discover none of them are actually relevant to you.

 

Or maybe you want the tldr version?

 

I understand. I am good now. "Jacques1" has answered my question. Cron job is what I'm looking for.

Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.