function uma_UserName in User Menu Avatar (User Image in Menu) 8.4
Same name and namespace in other branches
- 8.5 user_menu_avatar.module \uma_UserName()
Set $name value.
2 calls to uma_UserName()
- uma_apply_markup in ./
user_menu_avatar.module - Apply markup per menu link.
- uma_Markup in ./
user_menu_avatar.module - Build our new replacement markup.
File
- ./
user_menu_avatar.module, line 75 - Display user picture and/or user name in menu.
Code
function uma_UserName() {
// Instantiate $name to empty string.
$name = '';
// Check if we should show user name.
if (uma_CFV()['showName'] == 'yes') {
// Get our custom field name.
$customNameField = uma_CFV()['customNameField'];
// Check that custom field exists.
if (!empty(FieldConfig::loadByName('user', 'user', $customNameField)) && uma_getUser()['currentUser']->{$customNameField}->value != '') {
// Set $name as the value custom name field.
$name = uma_getUser()['currentUser']->{$customNameField}->value;
}
else {
// Set $name as default username.
$name = uma_getUser()['currentUser']
->getDisplayName();
}
}
return $name;
}