• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Custom Fields in userblurb

florencia

Active member
#1
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);
}
 

Brogan

XenForo moderator
Staff member
#4
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.
 

florencia

Active member
#5
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.
 

florencia

Active member
#6
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".
 

Amaury

Well-known member
#7
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.
He did not say that option made them show on the member list.
 

florencia

Active member
#8
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
 

Amaury

Well-known member
#9
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.
 

florencia

Active member
#10
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".
 

Martok

Well-known member
#11
To be, or not to be: that is the core.php.
What's in a custom field? That which we call a rose, by any other custom field would smell as sweet.
Now is the Helper of our discontent, made glorious summer by this sun of York.

:D