how to update a field created with field_create_instance I'm building a module which implements hook_enable to create fields.
But as I'm developing I noticed a error in my code causing fields to be created in a wrong way.

Is there a way to update these fields?
preferably using code so I can also use this code to hide these fields from lets say a user profile once the module is disabled.

here's my code that I used to create those fields:

//calling my function
popover_create_user_field('field_firstname', 'Voornaam', 'textfield', 1);

/**
 * field creator helper function
 */
function popover_create_user_field($field_name, $field_label, $field_type, $visible_on_registration_form = 1) {
    // Check if our field is not already created.   
    if (!field_info_field($field_name)) {
        $field = array(
            'field_name' =&gt; $field_name, 
            'type' =&gt; 'text', 
        );
        field_create_field($field);

        // Create the instance on the bundle.
        $instance = array(
            'field_name' =&gt; $field_name, 
            'entity_type' =&gt; 'user', 
            'label' =&gt; $field_label, 
            'bundle' =&gt; 'user',
            // If you don't set the "required" property then the field wont be required by default.
            'required' =&gt; TRUE,
            'settings' =&gt; array(
            // Here you inform either or not you want this field showing up on the registration form.
                'user_register_form' =&gt; $visible_on_registration_form,
            ),
            'widget' =&gt; array(
                'type' =&gt; $field_type,
            ),
        );
        field_create_instance($instance);
    }
}


Lets say I want to update the user_register_form visibility to 0 so it will be hidden.
You can use a combination of field_info_instance() and field_update_instance():

// Load the instance
$instance = field_info_instance('user', $field_name, 'user');

// Make whatever changes you need to, e.g.
$instance['settings']['user_register_form'] = 0;

// And save it again
field_update_instance($instance);