Accessing current users custom field

by Robster   Last Updated July 08, 2017 13:10 PM

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


Answers 1


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

Wim de Ruijter
Wim de Ruijter
July 27, 2017 13:34 PM

Related Questions



Custom form field not working on server

Updated April 26, 2017 10:10 AM


How can I call custom fields in a blog view?

Updated January 04, 2018 00:10 AM

custom field :: external params within helper.php

Updated January 08, 2018 13:10 PM