I had created the new fields in User:Fields named departments, phone, and mobile phone. How can I view it at my site like how username and email can be viewed? For now I'm using getUser() and getParam(), but only name, username, and email appeared. Where can I get the field name in Joomla? Please excuse my knowledge as I'm very new to Joomla. Thank you.

$registered = JAccess::getUsersByGroup(2); //change number in the brackets
$rows = '';

foreach($registered as $user_id) //loop every user exist
    echo "<br>";
    $user = JFactory::getUser($user_id);

    $rows .= '';
    $rows .= '' . $user->name . '';
    $rows .= '' . $user->username . '';
    $rows .= '' . $user->getParam('com_fields_departments') . '';
    $rows .= '' . $user->getParam('com_fields_phone') . '';
    $rows .= '' . $user->getParam('com_fields_mobile_phone') . '';
    $rows .= '' . $user->email . '';
    $rows .= '';    
echo $rows;

You can not do it like this, because that's responsibility of another component and not of the user Model/Class.

Use something like:

JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$fields = FieldsHelper::getFields('com_users.user', $user, true);
    $prop = str_replace('-','_',$field->name);
    $val = $field->value;
    $user->$prop = $val;

That's on fly produced example that is born from the code that worked for me at another project (initial code below)

JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$events = array_map(function($event){
    $event->images = (new Joomla\Registry\Registry())->loadString($event->images);
    $fields = FieldsHelper::getFields('com_content.article', $event, true);
        $prop = str_replace('-','_',$field->name);
        $val = $field->value;
        $event->$prop = $val;
    return $event;

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.