I am using Drupal 7.18 CMS. I have Webform with 6 fields as shown : Your name, User name, password, Email, phone number, Website. If we submit it will store in database, but here I need username & password should store in "User Account Registration form also". We can add fields from Configuration -> People -> Account settings for other fields, but It is not that situation. I need to store the User name & password values to "User Account Form" and then to login with that username and password. How can I proceed for this task. Please give me solution for this task as soon as possible.

Comments

nevets’s picture

The Drupal approach is to "add fields from Configuration -> People -> Account settings for other fields"

kshama_deshmukh’s picture

You can make a use of hook_webform_submission_insert

In the implementation hook_webform_submission_insert hook you need to make a use of user_save() function for registering the user on your site.

/**
 * Implementation of hook_webform_submission_insert()
 */
function my_registration_webform_submission_insert($node, $submission) {
  // $node->nid will be the node id of your webform
  if ($node->nid == 2) {
    $submitted_data = $submission->data;
    $user_name = $submitted_data[1]['value'][0]; 
    $password = $submitted_data[2]['value'][0];
    $email = $submitted_data[3]['value'][0];

    // Need to populate following data for registering the user.
    $user_data = array();
    $user_data['init'] = $email;
    $user_data['mail'] = $email;
    $user_data['name'] = $user_name;
    $user_data['pass'] = $password;
    $user_data['status'] = 1;
    $user_data['roles'] = array(); // You can specify any roles which you need
    user_save('', $user_data);
  }
}
SinhaM’s picture

I am new to Drupal. In which page I should I use this code, and how to pass the field values. Please expian me clearly? Thanks.

nevets’s picture

If you are new, using the standard registration with user fields would be simpler.

SinhaM’s picture

I need to send Email also after submitting the form. By using webform, we have email settings to send an email. So please explain me using Reg form with Webform.

nevets’s picture

Send to who?

The standard registration already sends an email to the new user and you can use rules to send a different email elsewhere.

SinhaM’s picture

User who filling the form.. then activation link will be sent.

SinhaM’s picture

I found the working functionality of above task from this Link - http://drupal.org/node/1336486 [Useful posts -> #5 or #6].

aaronbauman’s picture