Customize Email notification to include User Profile Field

Customize Email notification to include User Profile Field

by Lisa Fontenot -
Number of replies: 5

I am somewhat familiar with Language Customization, but have not been able to add the student/user’s City/Town {city/} and/or Institution {institution/} from the user profile field(s) into the email notification.

Is there a certain placeholder that needs to be incorporated into the language string for data to feed from the user profile field(s) into the email notification string?

Any guidance is much appreciated!

Average of ratings: -
In reply to Lisa Fontenot

Re: Customize Email notification to include User Profile Field

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Which particular string are you referring to? The only way to answer this is to check what placeholder values are passed into the relevant get_string() call. In most cases, only certain attributes are provided and typically all of them are then used in the standard English string. So introducing a new placeholder via the language customisation is not possible in most cases (and it is a performance related feature, not a bug).

Still chances are that in this particular case, the whole user object is provided as a data source for the $a placeholder, thence I am asking for the particular string identifier.

In reply to David Mudrák

Re: Customize Email notification to include User Profile Field

by Lisa Fontenot -

David, thank you for your reply! I didn't know if there is a particular placeholder (different from the $a) for user profile fields.

I found the language strings for city/town {city/} and institution {institution/} in the user profiles using the this link for Language customisation: https://docs.moodle.org/31/en/Language_customisation.

Then tried to incorporate the strings using place holder {$a} into my email subject, but the output is {$a->city} or {$a->institution}, not the data that is entered in the particular field of the user profile.

And, maybe placeholder is not the issue. I'm just not clear how to feed the city/town and/or institution data into my email language.

Thanks again for your response. smile


In reply to Lisa Fontenot

Re: Customize Email notification to include User Profile Field

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Where exactly do you type the notification email text? Are you referring to the course welcome message or something like that?

In reply to David Mudrák

Re: Customize Email notification to include User Profile Field

by Lisa Fontenot -

I'm trying edit my existing customized email subject notification in the mod_quiz emailnotifysubject:

Current working customized string is this: {$a->studentname} has completed {$a->quizname}

smile

In reply to Lisa Fontenot

Re: Customize Email notification to include User Profile Field

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

The list of available values for this particular $a placeholder is here: https://github.com/moodle/moodle/blob/v3.1.2/mod/quiz/locallib.php#L1596-L1616

Neither city nor institution is provided there. You might be able to add relevant lines into that code block to make it work (as long as you know what you are doing).

p.s. I am moving this discussion from the Languages into the Quiz forum.