PDA

View Full Version : Notify admin when user's paid subscription expired


kh99
07-16-2014, 01:27 AM
(See below)

Fields
07-16-2014, 06:23 AM
Hello,

I would like admins to be notified via PM or email, when a paid subscription of a user expired. Is there a way to set this up?

I appreciate your help!

Best regards,
Fields

kh99
07-16-2014, 01:28 PM
Hook location paidsub_delete is called when a subscription is deleted, so you could use that. The user information is in $user. You could probably check for THIS_SCRIPT == 'cron' so that you don't send a notification when a subscription is deleted via the admincp.

Subscriptions are also deleted from a cron job in includes/cron/ccbill.php, I think when billing for a recurring subscription fails, so if that applies to you, you can either check for it or just allow it to send a notification in that situation as well.

As for sending he actual notification, if you look at the end of includes/cron.subscriptions.php you can see where the email is sent for reminders. Of course you want your emails to go to the admin and not to the users, but the basic code for sending an email is there.

You could probably also send a PM, but cron is called by whatever user happens to trigger it, so I'm not sure if you'd run in to a problem where the PM sending code is trying to use information from the current user.

Edit: it looks like there was a problem with the server time, so that my reply appeared before your post and now I can't delete it without deleting the thread. That's why there's a "See below" post above.

Fields
07-16-2014, 04:12 PM
Thanks for your reply!
Unfortunately, I am too inexperienced to get this working :( Could you please give me more precise instructions on how to set this up? On condition that this isn't too laborious for you :)