1. 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?

Discussion in 'XenForo Development Discussions' started by Mic, Apr 4, 2013.

  1. Mic

    Mic Member

    How can I get a user custom field value in php?
  2. Jake Bunce

    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?
  3. Mic

    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'];
    Cyb3r likes this.
  4. Jeremy

    Jeremy Well-Known Member

    You shouldn't instantiate XenForo_Model_UserField directly. It should be:
    tyteen4a03 likes this.

Share This Page