2

I´ve added a custom users field (called "test"). Now I want to call the value of this custom field for the current user who is logged in.

In the mysql databse I see the custom field under _fields. So how can I call this specific field?

Normally I get the current user object like this:

$user=JFactory::getUser(); 
$userId=$user->get('name');

1 Answer 1

2

Basically you have all the custom fields corresponding to the current item accessible via a new property in your $item variable called jcfields. The $item->jcfields property is an array that holds data per field.

You could output the fields this way:

<?php foreach ($this->item->jcfields as $field) : ?>
// Render the field using the fields render method
<?php echo $field->label . ':' . $field->value; ?>
<?php endforeach ?>

See https://docs.joomla.org/Special:MyLanguage/J3.x:Adding_custom_fields/Overrides

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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