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

Adding Custom Fields into User Table

Discussion in 'XenForo Development Discussions' started by Feanux, Jul 28, 2013.

  1. Feanux

    Feanux Member


    I would like any custom profile titles I create to be added to the user table, as it's own category. What is the easiest way I could possibly achieve this?

    For example, already in the user table we have columns last_activity, trophy_points, etc. If I created a custom profile field called "Favorite Color", how would I be able to add that as it's own column in the user table, so I can easily sort members/fetch the information?


  2. Brogan

    Brogan XenForo Moderator Staff Member

    Custom user fields and the values are already automatically added to the database: xf_user_field and xf_user_field_value.
  3. Feanux

    Feanux Member

    I am using the Sort Member resource: http://xenforo.com/community/resources/raid101-com-member-list-manager.1421/

    The way that is setup is that you can create search critiers based on the format: table.column (however you can only grab from user and userprofile).

    Instead of reworking database stuff, is there a way I can search members based on keywords in their ABOUT section, or search based on custom fields?


  4. Brogan

    Brogan XenForo Moderator Staff Member

    Searching member profile content isn't possible.
  5. Feanux

    Feanux Member

    Is there a way I can break down how the custom_fields are stored in the database?

    Instead of having all custom fields in one column, can I change where a new field is stored? For example, if i create the column favcolor on the user_profile table, where can I go to change where that custom field is stored so it goes to favcolor column!
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Have a look in \library\XenForo\DataWriter\UserField.php
  7. Jeremy

    Jeremy Well-Known Member

    If you want to store information in a separate column you will need to write a custom add-on and manage storage of the information yourself. The custom fields are stored as a serialized array (or object, but I'm pretty sure its an array).

Share This Page