I'm using Moodle 3.3, and needed our teachers to receive an email each time a new student self-enrolled into a course.
I'm also running a heavily customised 1.9 version of Moodle, but the code doesn't work in the same way.
I have figured it out, and wanted to share my edits below, in case someone else needs the same.
/enrol/self/lib.php
Around line 406, replace:
email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
with
//New text below to send self-enrol emails to teachers tooYou'll also want to make sure the 'Send course welcome message' in the self enrol , enrolment method is set to Course Contact.
email_to_user($contact, $contact, $subject, $messagetext, $messagehtml);
email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
I've also customised the 'Welcome' email to have the following code in:
{$a->profileurl}
This will display the student's profile in the email, in the footer. This way the duplicated email (which the teacher now receives) can view the student's profile page from the email.