Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add a new user in drupal 7 programmatically ?My custom module defines a form with custom fields
    primarykey
    data
    text
    <p>Hi being a newbie to drupal , kindly guide how to add a new user , i know user module with user_save can be used but how and where to implement it ? <br /> Do i have to write this function in submit handler of my custom form below- <br /></p> <pre><code>function registerme_newform($form, &amp;$form_state) { $form = array(); $form['account details'] = array( '#type' =&gt; 'fieldset', '#title' =&gt; t('Account Details'), '#description' =&gt; t('Enter Personal Credentials'), ); $form['account details']['first name'] = array( '#type' =&gt; 'textfield', '#title' =&gt; t('First Name'), '#default_value' =&gt; t('Be sure of your first name'), '#attributes' =&gt; array( 'onblur' =&gt; "if (this.value == '') {this.value = 'Be sure of your first name'}", 'onfocus' =&gt; "if (this.value == 'Be sure of your first name') {this.value = ''}" , ), ); $form['account details']['last name'] = array( '#type' =&gt; 'textfield', '#title' =&gt; t('Last Name'), '#default_value' =&gt; t('Be sure of your last name'), '#attributes' =&gt; array( 'onblur' =&gt; "if (this.value == '') {this.value = 'Be sure of your last name'}", 'onfocus' =&gt; "if (this.value == 'Be sure of your last name') {this.value = ''}" , ), ); $form['account details']['email'] = array( '#type' =&gt; 'textfield', '#title' =&gt; t('E-Mail'), '#required' =&gt; TRUE, '#default_value' =&gt; t('Email acts as username.Dont forget it!'), '#attributes' =&gt; array( 'onblur' =&gt; "if (this.value == '') {this.value = 'Email acts as username.Dont forget it!'}", 'onfocus' =&gt; "if (this.value == 'Email acts as username.Dont forget it!') {this.value = ''}" , ), ); $form['account details']['password'] = array( '#type' =&gt; 'password', '#title' =&gt; t('Password'), '#maxlength' =&gt; 60, '#size' =&gt; 60, '#required' =&gt; TRUE, '#description' =&gt; t('Password should be atleast 6 characters long.'), ); $form['home'] = array( '#type' =&gt; 'fieldset', '#title' =&gt; 'Home Address', '#description' =&gt; t('Enter Personal Residential Credentials') ); $form['home']['street'] = array( '#type' =&gt; 'textfield', '#title' =&gt; 'Street Address', ); $form['home']['city'] = array( '#type' =&gt; 'textfield', '#title' =&gt; 'City', ); $form['work'] = array( '#type' =&gt; 'fieldset', '#title' =&gt; 'Work Address', '#description' =&gt; t('Enter Official Address') ); $form['work']['street'] = array( '#type' =&gt; 'textfield', '#title' =&gt; 'Street Address', ); $form['work']['city'] = array( '#type' =&gt; 'textfield', '#title' =&gt; 'City', ); $form['submit'] = array( '#type' =&gt; 'submit', '#value' =&gt; t('Register Me'), ); return $form; } function registerme_newform_validate(&amp;$form, &amp;$form_state) { if($form_state['values']['account details']['first name']=='Be sure of your first name') { form_set_error('first name',t('Please enter your first name')); } } function registerme_newform_submit(&amp;$form, &amp;$form_state) { dsm($form_state); } </code></pre> <p><br /> Also would like to know how will values be entered in database , i mean how will these custom fields be added to database? Kindly guide thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload