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

How to get a user custom field value in php?

Jake Bunce

XenForo moderator
Staff member
#2
It's in the user record.

What is the context? Are you working with a XenForo addon? Or are you talking about a raw PHP script that is separate from XenForo?
 
#3
Inside my add-on.

I found a way to get the value.

$userFieldModel = new XenForo_Model_UserField;
$values = $userFieldModel->getUserFieldValues($visitor['user_id']);
$myValue = $values['my_custom_field_id'];
 

Jeremy

Well-known member
#4
Inside my add-on.

I found a way to get the value.

$userFieldModel = new XenForo_Model_UserField;
$values = $userFieldModel->getUserFieldValues($visitor['user_id']);
$myValue = $values['my_custom_field_id'];
You shouldn't instantiate XenForo_Model_UserField directly. It should be:
PHP:
XenForo_Model::create('XenForo_Model_UserField');[/quote]