How to get a user custom field value in php?

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?
 
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'];
 
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]
 
Back
Top Bottom