User profile custom field in newusernewpasswordsubj

Re: User profile custom field in newusernewpasswordsubj

av Dave Varon -
Galle vástádusa: 0

I resolved this by customizing  

moodle/lib/moodlelib.php

specifically the function:

setnew_password_and_mail

more specifically, lines 5951-5953 (other lines incl. for context):

5943     $a = new stdClass();
5944     $a->firstname   = fullname($user, true);
5945     $a->sitename    = format_string($site->fullname);
5946     $a->username    = $user->username;
5947     $a->newpassword = $newpassword;
5948     $a->link        = $CFG->wwwroot .'/login/';
5949     $a->signoff     = generate_email_signoff();
5950
5951     require_once($CFG->dirroot.'/user/profile/lib.php');
5952     profile_load_data($user);
5953     $a->studyid      = $user->profile_field_StudyID;
5954
5955     $message = (string)new lang_string('newusernewpasswordtext', '', $a, $lang);
5956
5957     $subject = format_string($site->fullname) .': '. (string)new lang_string('newusernewpasswordsubj', '', $a, $lang);

and then I customized the "newusernewpasswordsubj" string in the language pack to use the {$a->studyid} placeholder.

H/t to Olumuyiwa Taiwo in his response to "Get Custom Fields info"  and to Shane Elliott in How do I get a custom profile field in the code?

Thanks eb,

Dave