Creation of drupal user profile fields in a module

I have been unable to find much example documentation for this method elswhere. If anyone has any better ideas please comment away!

The following code snippet creates a user profile field.

  $form_values = array(
    'title' => 'First Name',
    'name' => 'firstname',
    'explanation' => 'Your first name',
    'category' => 'Contact Information',
    'type' => 'textfield',
    'weight' => '0',
    'required' => '1',
    'register' => '1',
    'visibility' => '1',
    'autocomplete' => '0',
    'options' => '',
    'page' => ''
  );
    
  profile_field_form_submit(1, $form_values);
To create a profile field which is a select use the following code (the important bit is knowing how to format the options using \n to make the line breaks
  $form_values = array(
'title' => 'Title',
'name' => 'title',
'explanation' => 'Your salutation',
'category' => 'Personal Details',
'type' => 'selection',
'weight' => '0',
'required' => '1',
'register' => '1',
'visibility' => '1',
'autocomplete' => '0',
'options' => "Mr\nMrs\nMiss\nDr",
'page' => ''
);

profile_field_form_submit(1, $form_values);

 


Your rating: None Average: 3.8 (4 votes)