Would you mind showing a snippet?You'll have to insert them with MySQL via your install script.
Would you mind showing a snippet?
$writerData = array(
'field_id' => 'unique_id_for_field', // Unique Identifier for the field - probably best to prefix it with your add-on ID
'display_group' => 'preferences', // Group to display in: personal, contact, preferences
'display_order' => 10, // The position (relative to other fields in the group) to display this field at
'field_type' => 'textbox', // Type of field (textbox, textarea, select, radio, checkbox, multiselect)
'show_registration' => 0, // Whether to show on registration.
'required' => 1, // Whether the field is required.
'user_editable' => 1, // Whether the user can edit the field
'viewable_profile' => 1, // Show on profile
'viewable_message' => 1, // Show in postbit
);
$writer = XenForo_DataWriter::create('XenForo_DataWriter_UserField');
$writer->bulkSet($writerData);
$writer->save();
It's probably better to use the DataWriter during install.
See the installer of this add-on for an example:
https://xenforo.com/community/resources/display-e-mail-address-in-profile.810/
The code is ancient, and could be a bit slicker, but the basic premise is there.
Thank you both. This is exactly what I needed .Code:$writerData = array( 'field_id' => 'unique_id_for_field', // Unique Identifier for the field - probably best to prefix it with your add-on ID 'display_group' => 'preferences', // Group to display in: personal, contact, preferences 'display_order' => 10, // The position (relative to other fields in the group) to display this field at 'field_type' => 'textbox', // Type of field (textbox, textarea, select, radio, checkbox, multiselect) 'show_registration' => 0, // Whether to show on registration. 'required' => 1, // Whether the field is required. 'user_editable' => 1, // Whether the user can edit the field 'viewable_profile' => 1, // Show on profile 'viewable_message' => 1, // Show in postbit ); $writer = XenForo_DataWriter::create('XenForo_DataWriter_UserField'); $writer->bulkSet($writerData); $writer->save();
There are a few other fields you can use, reference XenForo_DataWriter_UserField for those
We use essential cookies to make this site work, and optional cookies to enhance your experience.