Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

276
Views
Moodle Enrolment Email for Teachers - Add Student Email Address

I'm running Moodle, and have a teacher who receives a notification email anytime a student enrolls in a course (via PayPal enrollment).

The email contents come from lang/en/enrol.php:

$string['enrolmentnewuser'] = '{$a->user} has enrolled in course "{$a->course}";

What I'm trying to do is include the student's email address in this, for the teacher to reference.

Here's what I've tried:

$string['enrolmentnewuser'] = '{$a->user} has enrolled in course "{$a->course}". Student\'s email address: {$a->email}';

To make this $a->email variable available, I went into the function that gets the email contents: enrol/flatfile/lib.php::process_records()

Inside process_records(), I added the following:

$a->email = $user->email;

I put this directly after these lines:

$a = new stdClass();
$a->course = format_string($course->fullname, true, array('context' => $context));
$a->user = fullname($user);

and before this line, which gets the email contents:

$eventdata->fullmessage = get_string('enrolmentnewuser', 'enrol', $a);

I would think that the $a object would now contain my new 'email' property, which would be accessible in the 'enrolmentnewuser' string.

I've cleared the cache after my updates.

Unfortunately, this is the email the teacher is now receiving:

Student has enrolled in course "Test Course". Student's email address: {$a->email}

It looks like the $a->email is not swapping the actual property into the message. For the life of me, I haven't been able to figure out why it's not working. It's been difficult to debug, as I have to keep enrolling and un-enrolling in the test course which is frustrating.

Does anyone have any insight into why this is printing the $a->email property name literally, instead of the actual property?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In your case, you need to add the below line to enrol/paypal/ipn.php file also.

 $a->email = $user->email;

put this directly after these lines:

 $a->course = format_string($course->fullname, true, array('context' => $coursecontext));
 $a->user = fullname($user);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!