custom certificate- how to display the Username field?

custom certificate- how to display the Username field?

gan 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? 



Cyfartaledd sgoriau: -
In reply to IQBAL Musthapa

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

gan Mark Nelson -
Llun o Core developers Llun o Documentation writers Llun o Particularly helpful Moodlers Llun o Peer reviewers Llun o Plugin developers Llun o 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.


Cyfartaledd sgoriau:Useful (1)
In reply to Mark Nelson

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

gan IQBAL Musthapa -

Ok will look at that code snippet , thanks!

In reply to Mark Nelson

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

gan 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?

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