WARNING: USE THIS SCRIPT AT YOUR OWN RISK. IT IS A TEMPORARY SOLUTION AND IS KNOWN TO REQUIRE A SIGNIFICANT AMOUNT OF RESOURCES TO RUN FOR LARGE DATASETS TO THE POINT WHERE SERVER TIMEOUTS CAN OCCUR. THE MEMBERMOUSE CUSTOMER SUCCESS TEAM CANNOT SUPPORT IN THE INTERPRETATION OR USE OF THIS SCRIPT.

DOWNLOAD SCRIPT HERE
 
This script will find all active subscriptions that will rebill in the X days where X is defined in the $daysPriorToRebill variable. The script will call the rebillReminderNotification() function for each active subscription that will rebill in X days passing on some useful data associated with the subscription.

A practical use of this script would be to run it on a cron and perform an appropriate action like sending an email to customers to remind them of the upcoming renewal.

IMPORTANT FACTORS TO CONSIDER:

This script doesn't have any native way of knowing if you've already performed the desired action in association with an active subscription. A solution should be put in place to address this otherwise a customer could end up receiving multiple reminder emails (assuming sending an email is the action you implement in the rebillReminderNotification() function).

With large datasets it's possible to overtax or timeout server resources especially if you're sending out emails. For example, it's possible with 2,000 members recurring monthly that a common execution of this script daily will result in over 100 matching subscriptions. If you simply attempt to send out 100 emails all at once this would at best be inefficient and at worst timeout.

If you make any enhancements to this script that you think would be valuable to others, please feel free to upload your changes back to our forum here and outline your enhancements:
http://support.membermouse.com/discussions/topics/9000003600