Using user custom fields in articles

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Fri Jan 14, 2011 8:44 pm

Using user custom fields in articles

Post by billh210 » Sun May 19, 2019 5:27 pm

I am trying to use User Custom Fields in articles and have been using this code without a problem.
But since 3.9 it stopped working. Any Ideas why this is working did something change in the custom fields?

$user = JFactory::getUser();
$field_name = $user-&gt;id;

$user = JFactory::getUser($field_name);
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$customFields = FieldsHelper::getFields('com_users.user', JFactory::getUser(), true);
echo $customFields[1]-&gt;value;

/* Change the number above to get differant custom Fields. [1] */

User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 117
Joined: Thu Sep 01, 2011 7:26 am
Location: Athens, Greece

Re: Using user custom fields in articles

Post by Pnkr » Wed May 22, 2019 7:44 am

There is no way that : echo $customFields[1]-&gt;value;

can work...
echo $customFields[1]->value;


Post Reply

Return to “General Questions/New to Joomla! 3.x”