Created
June 18, 2013 15:22
-
-
Save sebyoga/5806287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function MYMODULE_enable() { | |
// Check if our field is not already created. | |
if (!field_info_field('field_myField')) { | |
$field = array( | |
'field_name' => 'field_myField', | |
'type' => 'text', | |
); | |
field_create_field($field); | |
// Create the instance on the bundle. | |
$instance = array( | |
'field_name' => 'field_myField', | |
'entity_type' => 'user', | |
'label' => 'My Field Name', | |
'bundle' => 'user', | |
// If you don't set the "required" property then the field wont be required by default. | |
'required' => TRUE, | |
'settings' => array( | |
// Here you inform either or not you want this field showing up on the registration form. | |
'user_register_form' => 1, | |
), | |
'widget' => array( | |
'type' => 'textfield', | |
), | |
); | |
field_create_instance($instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment