You are here

function janrain_capture_create_field in Janrain Registration 7

Same name and namespace in other branches
  1. 7.4 janrain_capture.install \janrain_capture_create_field()
  2. 7.2 janrain_capture.install \janrain_capture_create_field()
  3. 7.3 janrain_capture.install \janrain_capture_create_field()

Programatically create a field (field_janrain_capture_uuid) on the User entity

1 call to janrain_capture_create_field()
janrain_capture_enable in ./janrain_capture.install
Implements hook_enable().

File

./janrain_capture.install, line 52
Uninstall functions for the janrain_capture module

Code

function janrain_capture_create_field() {

  // Check if our field is not already created.
  if (!field_info_field('field_janrain_capture_uuid')) {
    $field = array(
      'field_name' => 'field_janrain_capture_uuid',
      'type' => 'text',
      'translatable' => FALSE,
      'settings' => array(
        'max_length' => '255',
      ),
      'field_permissions' => array(
        'type' => '2',
      ),
    );
    field_create_field($field);

    // Create the instance on the bundle.
    $instance = array(
      'field_name' => 'field_janrain_capture_uuid',
      'entity_type' => 'user',
      'label' => 'Janrain Capture uuid',
      'bundle' => 'user',
      'required' => FALSE,
      'settings' => array(
        'text_processing' => '0',
        'user_register_form' => 0,
      ),
      'display' => array(
        'default' => array(
          'label' => 'above',
          'settings' => array(),
          'type' => 'hidden',
          'weight' => '3',
        ),
      ),
      'widget' => array(
        'active' => 1,
        'module' => 'text',
        'settings' => array(
          'size' => '60',
        ),
        'type' => 'text_textfield',
        'weight' => '2',
      ),
    );
    field_create_instance($instance);
  }
}