Andrew R Posted April 7, 2007 Share Posted April 7, 2007 Inactive Member Script I’m considering writing an inactive member script. For example if a user doesn’t log in for 30 days (1 month) or more they will receive an email. I’m struggling to work out how a script like this would work with any user input from the admin. Also things like dates. How would the system count back 30 days, i.e if the date is 2007-04-07, how would I count back 30 days? Any ideas would be much appreciated Cheers Quote Link to comment Share on other sites More sharing options...
MadTechie Posted April 7, 2007 Share Posted April 7, 2007 in the database have a field for last login, when the member logs inn, set that to the current time/date then to find member who haven't logined in just search in the database field for todays date minus 30days <?php $nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secs echo 'Now: '. date('Y-m-d') ."\n"; echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n"; // or using strtotime(): echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n"; ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 to actually do the email stuff if($then => $now) { $set _mail_param = "EMAIL BODY"; # set email params etc here mail($params_in_here); #id write to a database that the email was sent $now; } # then id check if the email was sent 30 days abo, then id suspend account or something if( $mail_time =< $then) { #youd do other stuff to get then and now do stuff to database to the account_status field or something } pm me if your confused good luck Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted April 8, 2007 Share Posted April 8, 2007 To do this automatically though, you will need to set up a cron job, which is basically shell code that is configured to run a certain script at a certain time that you set, I don't know exactly how it works, but look into it, otherwise it will require your input. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted April 8, 2007 Share Posted April 8, 2007 there are plenty of threads about crons, but the basics are: if you run windows, its exactly like a "scheduled task may hosts offer them, and its as simple as telling them where the script is, and how often to run it......... or you may have to code the cron your self, in which google would be the best place to get a quick tutorial........ you can simply set it to run every week, day, month, what ever you like, and even at specific times during the day....... so simply write your script, and "cron" it Quote Link to comment Share on other sites More sharing options...
Andrew R Posted April 9, 2007 Author Share Posted April 9, 2007 Cheers for the help and the scripts. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.