I'm looking for a way to send emails to users which certificate expired (or to users which passed quiz some time ago). The best way that will fit me is to not involve in certificate/quiz module files. I think that cron is going to be the best solution, but have no idea about setting up cron jobs.
Asked
Active
Viewed 720 times
0
-
Did you take a look at [this](http://stackoverflow.com/questions/18737407/how-to-create-cron-job-using-php) SO question for cron jobs from php? – kayess Jun 30 '16 at 08:57
-
Yes I read it but have no idea where to set up proper job: in cron.php which lay on m web server or in moodle cron.php. Also I don't know much about cron syntax. Generally I need to select some data from db and run job if criteria was fulfilled. – bgolemba Jun 30 '16 at 09:02
1 Answers
0
Which version of Moodle are you using? Cron is the old way, from Moodle 2.7+ you should use scheduled tasks.
In summary, create a local plugin
https://docs.moodle.org/dev/Local_plugins
Then add a scheduled task to get all certificates past the expiry date
https://docs.moodle.org/dev/Task_API
Then use messaging to send an email - take a look at this answer (ignore the event code)
Email using cron and including attachment to email from moodle

Community
- 1
- 1

Russell England
- 9,436
- 1
- 27
- 41
-
Thanks for reply but I thougt that It could be easier. I thought about setting up cron to check certificate if expired if yes then it insert value to new column in certificate table to recognize next time if message was send. – bgolemba Jul 04 '16 at 05:22