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

XF 1.5 UserFields variables

#1
What are the available variables in Custom User Field "Value Display HTML"?
I am trying to insert link to user profile, but it doesnt work:

href="/member/{$user.username}.{$user.user_id}/"
 

Jake Bunce

XenForo moderator
Staff member
#2
The available tokens are in the description of that box:

If not empty, this allows you to format the value of this field using HTML, allowing you to do things like link or mark up the output. You may use these placeholders: {$value} - the field's display value; {$valueUrl} - the field's display value for use in a URL; {$choice} - the underlying value of the chosen option; and {$fieldId} - the ID of this field (N/A).
These are straight string replacements in the code:

library/XenForo/ViewPublic/Helper/User.php

Code:
		if (!empty($field['display_template']))
		{
			if ($multiChoice && is_array($value))
			{
				foreach ($value AS $choice => &$thisValue)
				{
					$thisValue = strtr($field['display_template'], array(
						'{$fieldId}' => $field['field_id'],
						'{$value}' => $thisValue,
						'{$valueUrl}' => urlencode($thisValue),
						'{$choice}' => $choice,
					));
				}
			}
			else
			{
				$value = strtr($field['display_template'], array(
					'{$fieldId}' => $field['field_id'],
					'{$value}' => $value,
					'{$valueUrl}' => urlencode($value),
					'{$choice}' => $choice,
				));
			}
		}
 

Mike

XenForo developer
Staff member
#4
The short answer is you can't. Those details aren't available; only the ones Jake mentioned.