custom certificate- how to display the Username field?

custom certificate- how to display the Username field?

par IQBAL Musthapa,
Nombre de réponses : 4

Hi everyone

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



Moyenne des évaluations: -
En réponse à IQBAL Musthapa

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

par Mark Nelson,
Avatar Core developers Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers Avatar 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.


Moyenne des évaluations:Useful (1)
En réponse à Mark Nelson

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

par 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

En réponse à IQBAL Musthapa

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

par 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')
);