Additional name fields
Previous to Moodle 2.6 we only had two user name fields: First name and Surname (last name). This can be very restrictive depending on the country or culture that is using Moodle. The Moodle Association of Japan (http://moodlejapan.org) was specifically vocal about the need to include more information for users and created MDL-31776.
What has changed?
Full name format
The setting for fullnamedisplay (Full name format) has been moved from [Administration ► Site administration ► Security ► Site policies] to [Administration ► Site administration ► Users ► Permissions ► User policies]. It was decided that this setting made more sense being located with other user display information such as hiddenuserfields (Hide user fields) and showuseridentity (Show user identity).
The setting has changed from a select menu to a text box. An upgrade from a previous version will keep the old settings intact.
The fullnamedisplay setting now uses place holders. These are:
These place holders can be arranged in any order required and punctuation can now also be included. e.g. "firstname (middlename) lastname" to output "Robert (Bruce) Bannner".
The fullname function
The fullname function now requires a USER object that includes the new additional name fields (firstnamephonetic, lastnamephonetic, middlename, alternatename). If your code does not provide these extra fields then the following debugging message will be displayed: "You need to update your sql query to include additional name fields in the user object."
The recommended way to retrieve all of the information for displaying user detail is to use the user_picture::fields() function, especially if you plan on displaying a user picture. e.g.
$extrauserfields = get_extra_user_fields_sql($context); $mainuserfields = user_picture::fields(); $sql = "SELECT $mainuserfields, $extrauserfields"; ...
This is a new function which can be used for retrieving the user name fields in either a string or an array. This is useful for specific sql queries that do not require the user picture information and require some additional complexity.
This function was created to assist with displaying table headings correctly. It returns an array of values in order of occurrence in a provided string. The array key is the character position in the string that was provided.
This issue is not fully complete, there are still some areas that need changing and improving.