custom certificate- how to display the Username field?

custom certificate- how to display the Username field?

by IQBAL Musthapa -
Number of replies: 4

Hi everyone

been searching high and low; how do I insert the username field into my custom cert output? 



Average of ratings: -
In reply to IQBAL Musthapa

Re: custom certificate- how to display the Username field?

by Mark Nelson -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Unfortunately this can only be done by a developer.

You would need to create another element (see mod/customcert/element) and have it display the username, it wouldn't be too hard to do.


Average of ratings: Useful (1)
In reply to Mark Nelson

Re: custom certificate- how to display the Username field?

by IQBAL Musthapa -

Ok will look at that code snippet , thanks!

In reply to Mark Nelson

Re: custom certificate- how to display the Username field?

by Aaron Cauchi -

Hi, can you be a bid more elaborate as to quote "(see mod/customcert/element)"? how can I access via moodle this section? Need to insert the username in the certificate

Thanks


Aaron Cauchi

In reply to IQBAL Musthapa

Re: custom certificate- how to display the Username field?

by Henry Endara -
You can add the username field in the list of the user fields.
You need edit file /mod/customcert/element/userfield/classes/element.php , in this file you add username field in array $userfields.
For example after 'idnumber' you can add 'username'
you need add following line
'username' => get_user_field_name('username'),
So the complete array is
$userfields = array(
'firstname' => get_user_field_name('firstname'),
'lastname' => get_user_field_name('lastname'),
'email' => get_user_field_name('email'),
'city' => get_user_field_name('city'),
'country' => get_user_field_name('country'),
'url' => get_user_field_name('url'),
'icq' => get_user_field_name('icq'),
'skype' => get_user_field_name('skype'),
'aim' => get_user_field_name('aim'),
'yahoo' => get_user_field_name('yahoo'),
'msn' => get_user_field_name('msn'),
'idnumber' => get_user_field_name('idnumber'),
'username' => get_user_field_name('username'),
'institution' => get_user_field_name('institution'),
'department' => get_user_field_name('department'),
'phone1' => get_user_field_name('phone1'),
'phone2' => get_user_field_name('phone2'),
'address' => get_user_field_name('address')
);