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

Add/Remove custom profile fields upon installation/uninstallation?

Discussion in 'XenForo Development Discussions' started by Z61, Feb 4, 2015.

  1. Z61

    Z61 Member

    Is it possible to add or remove custom profile fields upon installation? If it is, can someone please lead me in the correct direction? I can't seem to figure it out and searching didn't provide what I am looking for.
  2. Jake B.

    Jake B. Well-Known Member

    You'll have to insert them with MySQL via your install script.
  3. Z61

    Z61 Member

    Would you mind showing a snippet?
  4. Chris D

    Chris D XenForo Developer Staff Member

    Z61 likes this.
  5. Jake B.

    Jake B. Well-Known Member

    $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');
    There are a few other fields you can use, reference XenForo_DataWriter_UserField for those :)
    Z61 likes this.
  6. Z61

    Z61 Member

    Thank you both. This is exactly what I needed :).
    CaptainMorgan and Chris D like this.

Share This Page