I'm trying to send an e-mail to the user after every course he/she completes. It's just a simple e-mail such as "Congratulations on completing this course!"
I found in an older post where someone did something similar, but when I try and replicate his method in the /course/completion_completion.php file, it breaks. Has anyone does something similar to this? I couldn't find a plugin that replicates this. Any help is appreciated.
The code I followed as a reference is below:
- Open the file root\enrol\manual\ajax.php
- First add below code to top
require_once($CFG->libdir.'/moodlelib.php');
$body = "You have been enrolled to course"." ".$course->fullname."<br/><br/>"."Please login to start your course."."<br/><br/>"."Thanks,"."<br/>LogicStrat Admin";
- Then find the code json_encode($outcome); & add below code in above this json.
Add email_to_user($user,$USER,'Enrollment Notification','The text of the message',$body);
- Then save & check when admin can manually enroll a course to student then student will get the notification.