Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all please check if the first name is allowed user name. I recommend you providing another field to enter username as its not uncommon that username is already used by somebody else. Then also check that there are no users registered with the given email address.</p> <pre><code>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')); } // TODO: Provide user with a chance to enter a name ( drupal user name ) // Also do the following two checks and report an error. // check using user_load_by_name($form_state['values']['account details']['first anme']) // check using user_load_by_mail($form_state['values']['account details']['email']) } </code></pre> <p>Next in your submit function map the form values to an array that could be passed to user_save as shown bellow. If you want to know exactly how other fields map, use the devel module to inspect the structure by vising an already existing user profile.</p> <pre><code>function registerme_newform_submit(&amp;$form, &amp;$form_state){ $new_user = array( // The below name field must be unique. 'name' =&gt; $form_state['values']['account details']['name'], 'pass' =&gt; $form_state['values']['account details']['password'], 'mail' =&gt; $form_state['values']['account details']['email'], 'init' =&gt; $form_state['values']['account details']['email'], 'field_first_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['account details']['first name']))), 'field_last_name' =&gt; array(LANGUAGE_NONE =&gt; array(array('value' =&gt; $form_state['values']['account details']['last name']))), // Map all the extra fields to user objects as shown above. ... 'status' =&gt; 1, 'access' =&gt; REQUEST_TIME, 'roles' =&gt; $roles, ); // $account returns user object $account = user_save(null, $new_user); //after user_save you can use the following code to send notification email. drupal_mail('user', 'register_no_approval_required', $account-&gt;mail, NULL, array('account' =&gt; $account), variable_get('site_mail', 'noreply@mysite.com')); } </code></pre>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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