Adding a field to users from a module.install file Is it possible to add a custom field to users from a module.install file, as it would be done from admin/config/people/accounts/fields?
It is possible, in the same way forum_enable() adds a new field to the "forum" content type; the only difference is that "entity_type" and "bundle" are both set to "user."

// Create the 'taxonomy_forums' field if it doesn't already exist.
if (!field_info_field('taxonomy_forums')) {
  $field = array(
    'field_name' =&gt; 'taxonomy_forums', 
    'type' =&gt; 'taxonomy_term_reference', 
    'settings' =&gt; array(
      'allowed_values' =&gt; array(
        array(
          'vocabulary' =&gt; $vocabulary-&gt;machine_name, 
          'parent' =&gt; 0,
        ),
      ),
    ),
  );
  field_create_field($field);
}

// …

// Create the instance on the bundle.
$instance = array(
  'field_name' =&gt; 'taxonomy_forums', 
  'entity_type' =&gt; 'node', 
  'label' =&gt; $vocabulary-&gt;name, 
  'bundle' =&gt; 'forum', 
  'required' =&gt; TRUE, 
  'widget' =&gt; array(
    'type' =&gt; 'options_select',
  ), 
  'display' =&gt; array(
    'default' =&gt; array(
      'type' =&gt; 'taxonomy_term_reference_link', 
      'weight' =&gt; 10,
    ), 
    'teaser' =&gt; array(
      'type' =&gt; 'taxonomy_term_reference_link', 
      'weight' =&gt; 10,
    ),
  ),
);
field_create_instance($instance);


You can implement a similar code in the hook_enable() implementation of your module, or in the hook_install() implementation; in the first case, you should check if the field doesn't already exists, or field_create_instance() raises an exception.

To verify the field doesn't already exist, you can use code similar to the following one, where $instance is the same array as used in the previous code:

$prior_instance = field_read_instance($instance['entity_type'], $instance['field_name'], $instance['bundle']);
if (empty($prior_instance)) {
  field_create_instance($instance);
}