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

XF 1.1 Default Value of Custom User Fields

Discussion in 'XenForo Questions and Support' started by Lycaon, Aug 19, 2012.

  1. Lycaon

    Lycaon Well-Known Member

    Unless I've overlooked it somewhere, I know you can't set a default value when creating custom fields but is there a way I can insert a default value at registration?

    I know you can set the field to show up on the registration form but I want it to be already filled in and not need the user to select anything.

    I'm more than happy to extend the registration process to insert the value straight into the database but I have no idea where or how to do that.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    In terms of direct db queries, you would have to insert a record into the xf_user_field_value table and then update the cache in xf_user_profile.custom_fields. If you are extending the register controller then you can use the user datawriter or user model which has a function to rebuild the cache:

    XenForo_Model_User::rebuildCustomFieldCache
     

Share This Page