Redirect to custom URL while logging in user through Webform I am hoping to register/login a user based on the values entered in Webform and then redirect to a URL based on a user type.

The problem is that everything works but the redirection. Seems like this line is the culprit:-
$form['#submit'][] = 'my_submit_handler_for_registration';

Any help?

Thanks 

Here is what I have done:-

function MYMODULE_webform_submission_insert($node, $submission) {


  $submitted_data = $submission-&gt;data;
    $full_name = $submitted_data[1][0];
    $user_name = $submitted_data[2][0];
    $password = $submitted_data[7][0];
    $fmno = $submitted_data[3][0];
    $role = $submitted_data[4][0];
    $where = $submitted_data[5][0];
    $when = $submitted_data[6][0];

    // For Redirection
    variable_set("redirect_to", $role);


    // Need to populate following data for registering the user.
    if ( empty($user_name)) {
      echo "&lt;h2 style='font-size: 18px; font-family: Helvetica Neue, sans-serif !important; color: #A80C0C; '&gt;No Username Found.&lt;/h2&gt;";

      exit();
    }
    $user_data = array();
    $user_data['init'] = $user_name;
    $user_data['mail'] = $user_name;
    $user_data['name'] = $user_name;

    $user_data['field_full_name']['und'][0]['value'] = $full_name;
    $user_data['field_fmno']['und'][0]['value'] = $fmno;
    $user_data['field_interviewee_role']['und'][0]['value'] = $role;
    $user_data['field_where']['und'][0]['value'] = $where;
    $user_data['field_when']['und'][0]['value'] = $when;
    $user_data['pass'] = $password;
    $user_data['status'] = 1;

    $user_data['roles'] = array(); // You can specify any roles which you need



    $tomorrow_date = time() + (60 * 60 * 24);
    $date_after_two_days = time() + (60 * 60 * 48);

    // Check if any previous user with the same email exists?
    $previous_user = user_load_by_mail($user_name);

    if(!empty($previous_user)) {
      echo "&lt;h2 style='font-size: 18px; font-family: Helvetica Neue, sans-serif !important; color: #0065bd; '&gt;Another user exists with the same email. Please login or enter another user.&lt;/h2&gt;";
    }
    else {

      //It'll add a new user here.
      $user = user_save('', $user_data);

      /*
      $arr = array ('name'=&gt;$user_name,'pass'=&gt;$password);
      // Finalize user login (modify $_SESSION, set login time in db)
      user_login_finalize($arr); */


      $form_state = array();
      $form_state['uid'] = $user-&gt;uid;
      //$form_state['redirect'] = 'registration';
      user_login_submit(array(), $form_state);
      //$new_user = user_load_by_mail($user_name);






    }


    return theme('register', array('output' =&gt; $submission));


}


function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {


  if ($form_id == 'webform_client_form_31') {
     $form['#submit'][] = 'my_submit_handler_for_registration';
  }
}

function my_submit_handler_for_registration(&amp;$form, &amp;$form_state) {

  $redirecting_to = variable_get("redirect_to");
  if($redirecting_to == "McKinsey Solutions") {
    $redirecting_to = "frontmso";
  }
  else {
    $redirecting_to = "";
  }
  $form_state['redirect'] =  $redirecting_to;
}
Another current question here inspired me for this short solution within your hook_webform_submission_insert():

 // Create user account.
 $my_user = user_save(NULL, $user_data);
 // Whether the user account was created successfully.
 if (!empty($my_user-&gt;uid)) {
   global $user;
   $user = $my_user;
   user_login_finalize($user_data);
   // Do the redirect here.
   drupal_goto('target_uri');
 }
 else {
   // User account could not be created. So do some error handling.
 }