Automatic emails before account expiration

5 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 14, 2012   (RSS)

Hi All,

Using the website membership plugin, I ’d like to be able to automatically send an email to a member x days before their membership account expires (using the expiresDate and email fields in the accounts database) and then to send them another email on their expiration date.

I was wondering if anyone has worked up anything like this and is willing to share?

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Automatic emails before account expiration

By Dave - April 27, 2012

Hi Jerry,

It's always a bit tricky to send emails at set intervals and track it, but here's one way:

- You add a checkbox called: preExpiryReminderSent
- And add a checkbox called: expiryReminderSent
- You make a php script that runs as a cronjob once daily
- You load all the users where (this is pseudo-code):
(expiryDate - x days) < NOW AND preExpiryReminderSent != 1
and for each user send an email and then set the preExpiryReminderSent =1
- Then load all the users where (this is pseudo-code):
(expiryDate) < NOW AND expiryReminderSent != 1
and for each user send an email and then set the expiryReminderSent =1
- Then when they renew set both those checkboxes to 0

Note: When testing email code, test it well and output the results to the screen first with "Sending reminder to email@example.com" so you can work out any bugs without spamming your users.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Automatic emails before account expiration

By gkornbluth - May 13, 2012

Hi Dave,

Thanks for your expert guidance on this. I got the function to work perfectly, members are now reminded 30 and 7 days before their expiration date, and I've learned a lot about cron jobs.

However, when the cron job runs, I get the following errors in the cron daemon report, and I'm not sure how to approach eliminating them. Hope you've got some more of your masterful insights to share.

X-Powered-By: PHP/5.2.17
Content-type: text/html; charset=utf-8


Notice: Undefined index: SCRIPT_FILENAME in /hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/plugins/createPDF/createPDF.php on line 22

Notice: Undefined index: HTTP_HOST in /hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/plugins/createPDF/createPDF.php on line 23

Notice: Undefined index: SCRIPT_NAME in /hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/plugins/createPDF/createPDF.php on line 23

Notice: Undefined variable: _SESSION in /hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/lib/login_functions.php on line 88


Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Automatic emails before account expiration

By Dave - May 14, 2012

Hi Jerry,

For the PHP headers, are you able to specify the command line that calls the cronjob script? If so you can add -q to supress PHP's HTTP headers. Like this:
php -q /path/to/script.php

That should remove the powered by and content type headers.

For the PHP notices, a workaround might be to edit /lib/init.php and add this line just above "// define constants"

error_reporting(E_ALL & ~E_NOTICE); // show all errors but notices

// define constants


Let me know if those work for you.
Dave Edis - Senior Developer
interactivetools.com