2.5.1 - Email Confirmation (moodle.php)

2.5.1 - Email Confirmation (moodle.php)

av Jane Booth -
Galle vástádusa: 7

Hi all - I am trying to customise the emailconfirmation string (moodle.php) which currently looks like this:

Hi {$a->firstname}, A new account has been requested at '{$a->sitename}' using your email address. To confirm your new account, please go to this web address: {$a->link} In most mail programs, this should appear as a blue link which you can just click on. If that doesn't work, then cut and paste the address into the address line at the top of your web browser window. If you need help, please contact the site administrator, {$a->admin}

Although that looks as though it would only enter the user's first name in the email confirmation, it's sending 'Hi FirstName LastName' - which I hate!!

Any suggestions?

Gjennomsnittlig vurdering: -
Vástádussan geasa: Jane Booth

Re: 2.5.1 - Email Confirmation (moodle.php)

av Robert Brenstein -
The code calling this string must be passing full name in the "firstname". You would need to change that code.
Vástádussan geasa: Robert Brenstein

Re: 2.5.1 - Email Confirmation (moodle.php)

av Jane Booth -

Thanks for your reply - would you be able to let me know how to do that?

Vástádussan geasa: Jane Booth

Re: 2.5.1 - Email Confirmation (moodle.php)

av Robert Brenstein -
I don't have version 2.5.1 handy to double-check, but it should be the same as in the earlier version: open file moodlelib.php and find function send_confirmation_email. There should be a line

data->firstname = fullname($user);

comment it out by inserting // in front of it and insert a new line:

data->firstname = $user->firstname;
Vástádussan geasa: Robert Brenstein

Re: 2.5.1 - Email Confirmation (moodle.php)

av Jane Booth -

I can't find a moodlelib.php at all... I'm in Site admin> Language> Language Customisation... is that the right path?

I can't seem to find anywhere that I can adjust the 'placeholders'. Any more clues?

Vástádussan geasa: Jane Booth

Re: 2.5.1 - Email Confirmation (moodle.php)

av Robert Brenstein -
You are looking in the wrong place it seems. Language customisation allows you to modify the language files. We are talking now about modifying the program itself. Your problem can't be fixed by modifying a language file. You need to access the server directly (not through Moodle) and edit one of the Moodle's program files. It is in the lib folder.
Vástádussan geasa: Robert Brenstein

Re: 2.5.1 - Email Confirmation (moodle.php)

av Peter Mott -

I am using 2.6 and wanted to start the email confirmation template with 'Dear Dr. {$a->lastname}'. But if you add this to the language pack it remains unsubsituted.

The code in lib/moodlelib.php  send_confirmation_email($user) looks as if it could be modifed by adding a line $data->lastname = $user->lastname  (as per Robert Brenstein's comment). In Moodle 2.6 this does not work. 

There is a fix described in http://docs.moodle.org/26/en/Additional_name_fields.

Following the instructions I changed the default way of addressing users to 'firstname lastname' and restored {$a->firstname} to the template. This results in a confirmation email 'Dear Dr. John Smith'. 

 

-- Peter