Unable to create userfield.

Renari

Member
Code:
        $dw = XenForo_DataWriter::create('XenForo_DataWriter_UserField');
        $dw->set('field_id', 'Field');
        $dw->set('display_group', 'contact');
        $dw->set('display_order', 130);
        $dw->set('field_type', 'textbox');
        $dw->set('match_type', 'none');
        $dw->set('user_editable', 'yes');
        $dw->save();
From what I understand, this should add a new userfield in the contacts section named "Field" however from what I've seen it's doing nothing when run as an install method for an addon.
 

Chris D

XenForo developer
Staff member
Seems to be correct.

Are you sure the install method is set up properly and is running?

Any errors in the server error log?
 

Renari

Member
Are install routines run when you create a new addon and supply an install method? Also, not seeing any errors in the error log. Here's an example.
 

Attachments

Chris D

XenForo developer
Staff member
The install routine is run when you install or upgrade an add-on (they run in the background, directly before the Rebuilding Caches page).

So, basically upgrade the add-on with the XML file and the install should run.

Everything seems fine, as far as I can tell. Not got time to install it myself and check, but it does seem ok.
 

Renari

Member
Thanks, it seems that the install routine is not run when you create a new addon from the development tab of the admin control panel. Uploading the XML for the add-on did indeed make it run and I found a new userfield added.
 
Top