XF 1.1 Default Value of Custom User Fields

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.
 
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
 
Top Bottom