As designed Custom User Field Phrases not staying associated with add-on

Steve F

Well-known member
#1
I have a add-on where I create some user fields upon install.

Example:

Code:
  $dw = XenForo_DataWriter::create('XenForo_DataWriter_UserField');
            //Steam
            $dw->set('field_id', 'steamUserProfile');
            $dw->set('display_group', 'contact');
            $dw->set('display_order', 1);
            $dw->set('field_type', 'textbox');
            $dw->set('required', 0);
            $dw->set('show_registration', 0);
            $dw->set('user_editable', 'yes');
            $dw->set('viewable_profile', '1');
            $dw->set('viewable_message', '1');
            $dw->save();
When creating the add-on I made the custom user fields and then associated the user_field_steamUserProfile and user_field_steamUserProfile_desc with the add-on. Now anytime I go back and make a change to the custom user field it removes any association that it had with the add-on.

Before editing user field
upload_2014-7-14_23-41-8.png

After Editing user field

upload_2014-7-14_23-41-48.png

When I say edit user field, all I did was open the user field to edit and hit save.
 

Mike

XenForo developer
Staff member
#2
User fields are "custom" and thus aren't associated with an add-on and as such, the phrases won't be either. You should simply create the phrases without an add-on.
 

Sim

Well-known member
#3
What is the recommended way of soliciting preferences from a user in an add-on?

User fields are an ideal way of asking for users to choose their preference or set custom profile information.

However, since we can't directly associate a user field with an add-on, we potentially leave ourselves open to issues if we create the custom user field programattically during add-on installation - especially if the administrator then goes and edits the user field by hand.

Is there a better way?
 

Mike

XenForo developer
Staff member
#4
You would need to create a preference field like the various "standard" preferences (new field in the DB, etc).
 
Top