Where do I customize the email sent when a new message is sent to a user?

Re: Where do I customize the email sent when a new message is sent to a user?

by Sergio Tapia -
Number of replies: 0

Great, I managed to find the exact area in the source files I need to modify.

/messages/lib.php : line - 2042

This is how the default Moodle code looks like:

$s->url = $CFG->wwwroot.'/message/index.php?user='.$userto->id.'&id='.$userfrom->id;

 

Here is the change I have already made in order for the course name and link to show up in the message window when somebody clicks the link to the conversation.

# This is where we're going to change the URL that is sent along with the email when a new
# message is sent to a user.
$s->url = $CFG->wwwroot.'/message/index.php?user='.$userto->id.'&id='.$userfrom->id.'&courseId='.'2';

 

I've already worked out the details on how to wire this up. I just need to figure out how to provide the correct course ID value to the GET parameter listed there in the code above.

As my code stands, I've hard coded a static '2' value for courseId just to test it out, and it works fine.

Is there a way for me to find out the course the user was in previously and place that value there? I notice there's a CONTEXT_COURSE variable in the original code, but I'm not sure if this is what I need to use or even how to use it.

 

I really appreciate the help. Once I'm done I'll write a small tutorial as I'm sure I'm not the first or last one who needs this sort of functionality.