XF 1.2 Custom Fields in userblurb

florencia

Active member
how do I add a custom field in the userblurb? I would like to have: forum title, full name (custom field), organization (custom field), occupation/job title (custom field), location.

I removed the fields i don't want like gender in core.php, but how do I add the custom fields?

/**
* Helper, for the user blurb "Title, gender, age, from location".
*
* @param array $user
* @param boolean Include user title in blurb
*
* @return string
*/
public static function helperUserBlurb(array $user, $includeUserTitle = true)
{
if (!is_array($user) || empty($user['user_id']))
{
return '';
}

$parts = array();

if ($includeUserTitle && $userTitle = self::callHelper('usertitle', array($user)))
{
$parts[] = '<span class="userTitle" itemprop="title">' . $userTitle . '</span>';
}

/**if (!empty($user['gender']))
*{
* $parts[] = new XenForo_Phrase($user['gender']);
*}
*
*if (!isset($user['age']) && !empty($user['show_dob_year']) && !empty($user['dob_year']))
*{
* $user['age'] = self::_getModelFromCache('XenForo_Model_UserProfile')->getUserAge($user);
*}
*
*if (!empty($user['age']))
*{
* $parts[] = $user['age'];
*}
*/
if (!empty($user['location']))
{
$user['locationCensored'] = XenForo_Helper_String::censorString($user['location']);

$location = '<a href="'
. XenForo_Link::buildPublicLink('misc/location-info', '', array('location' => $user['locationCensored']))
. '" class="concealed" target="_blank" rel="nofollow">'
. htmlspecialchars($user['locationCensored'])
. '</a>';

$parts[] = new XenForo_Phrase('from_x_location', array('location' => $location), false);
}

return implode(', ', $parts);
}
 
Custom user fields are already shown on profiles, under the Information tab.

They can also be shown in the message user info block by enabling Style Properties -> Message Elements: Show custom user fields

I haven't checked if the data is available in the member list. I suspect not so it will require custom development.
 
The enabling Message Elements worked for the user card on the left of the threads but did not for the members list like you correctly suspected. I will see if I manage to work that one out. Thank you.
 
How would you add the custom field to the core.php, I have tried {$user.customFields.field_id} but it doesn't work. I want to add a custom field to the Helper, for the user blurb "Title, gender, age, from location, custom field".
 
I know... thats why I said "like you correctly suspected." mmm? I don't understand what you are saying... please elaborate your conspiracy theory... LOL

If you knew, then you wouldn't have said that.

I elaborated quite perfectly what I meant.

But this isn't the place for this, so I digress.
 
Maybe William Shakespeare here (Amaury) can let us get back to what really matters after a small distraction, I ask again...

How would you add the custom field to the core.php? I have tried {$user.customFields.field_id} but it doesn't work. I want to add a custom field to the Helper, for the user blurb "Title, gender, age, from location, custom field".
 
500pxHA_HA_HA_OH_WOW.jpg
 
Back
Top Bottom