Creating/registering a user (of a custom profile type) when a certain webform is submitted? Before all else - Here's my current code.

function hook_webform_submission_insert($node, $submission) {

  $password = user_password(8);

  //set up the user fields
  $new_user = array(
    'name' =&gt; $form_state['values']['e_mail'],
    'mail' =&gt; $form_state['values']['e_mail'],
    'pass' =&gt; $password,
    'status' =&gt; 0,
    'init' =&gt; $email,
    'roles' =&gt; array(
      DRUPAL_AUTHENTICATED_RID =&gt; 'authenticated user', 
      6 =&gt; 'custom role',
    ),
    'field_dealer_fname'=&gt; $form_state['values']['first_name'];
    'field_dealer_lname' =&gt; $form_state['values']['last_name'];
    'field_dealer_company' =&gt; $form_state['values']['company_name'];
    'field_dealer_phone' =&gt; $form_state['values']['phone'];
  );
 $account = user_save(null, $new_user)

    -&gt;execute();
}


I'm very new to Drupal, but intermediate experienced in Web dev in general. I just recently inherited a client from a previous employee before I joined, and he exclusively used Drupal (7, at that.)

Anyways, he previously had a system to set up a new user through this user-submitted webform, but that functionality apparently died 2 months ago in some sort of host migration. Now, I'm trying to figure out a way to accomplish this task with the already existing webform (v 3.27) and database.

That being said, from what I've found, I'm trying to use a webform Submission Hook to call the (Webform) values 

first_name,
last_name,
company_name,
phone,
e_mail


to fill the adjacent (Custom) user profile fields of "Dealer_profile" (along with the default ones)

field_dealer_fname
field_dealer_lname
field_dealer_company
field_dealer_phone


So, referring back to my code, my thought process is: 

//create a random 8 char password
  $password = user_password(8);


I was thinking this would be the equivalent of saying "these profile values = this user submitted value"

//set up the user fields
  $new_user = array(
    'name' =&gt; $form_state['values']['e_mail'],
    'mail' =&gt; $form_state['values']['e_mail'],
    'pass' =&gt; $password,
    'status' =&gt; 0,
    'init' =&gt; $email,
    'roles' =&gt; array(
      DRUPAL_AUTHENTICATED_RID =&gt; 'authenticated user', 
      6 =&gt; 'custom role',
    ),
    'field_dealer_fname'=&gt; $form_state['values']['first_name'];
    'field_dealer_lname' =&gt; $form_state['values']['last_name'];
    'field_dealer_company' =&gt; $form_state['values']['company_name'];
    'field_dealer_phone' =&gt; $form_state['values']['phone'];
  );


and ultimately, save this information and execute the hook?

 $account =    user_save(null, $new_user)

    -&gt;execute();


However, I feel like the hook itself is also wrong. This whole hooking thing in Drupal is a little odd to me, coming from mostly Wordpress use. Unfortunately the documentation is a little barebones, or in some way difficult for me to figure out how these things actually work. I was also just kind of thrown into this, and just have to figure everything out! Help is appreciated!
First you can add your code and add inside sites\all\modules\webform\includes\webform.submissions.inc in functions named "webform_submission_insert" , and check if it works or not , also as per below image in $submission variable you will get all webform submitted values .



Also , if you want to Get Webfrom submitted data by userid wise use below code anywhere.

module_load_include('inc', 'webform', 'includes/webform.submissions');
$values = webform_get_submissions($nid, null, $user-&gt;uid, 1);


if you want to Get Webfrom submitted data by node id , as below code 105 is node id.

module_load_include('inc', 'webform', 'includes/webform.submissions');  
$submissions = webform_get_submissions(105);