fetch user custom fields in article

by niaziblog   Last Updated May 14, 2019 16:10 PM - source

I have created some custom fields in user profile from backend

templates/name-template/html/com_content/article/default.php

and use this code for load custom fields at joomla article

<?php 
$context = 'com_content.article';
$article = $this->item;

//use the field helper class to get the fields
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
$fields = FieldsHelper::getFields($context, $article, true);
// Added so as to access fields by their name

// GET CUSTOM FIELDS
foreach($fields as $field) {
    $fields[$field->name] = $field;
}
?>

and use this code for fetch

<?php echo ($fields['name-field']->value); ?>

i creat textarea fileds at user profile for write about me (author) enter image description here now I want to fetch users custom fields (author) in joomla article How can i do it ؟



Related Questions




Custom form field not working on server

Updated April 26, 2017 10:10 AM