How to get a user custom field value in php?

Jake Bunce

XenForo moderator
Staff member
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?
 

Mic

Member
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
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]
 
Top