Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda