Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MYMODULE_webform_submission_insert($node, $submission) {
- $submitted_data = $submission->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 "<h2 style='font-size: 18px; font-family: Helvetica Neue, sans-serif !important; color: #A80C0C; '>No Username Found.</h2>";
- 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 "<h2 style='font-size: 18px; font-family: Helvetica Neue, sans-serif !important; color: #0065bd; '>Another user exists with the same email. Please login or enter another user.</h2>";
- }
- else {
- //It'll add a new user here.
- $user = user_save('', $user_data);
- /*
- $arr = array ('name'=>$user_name,'pass'=>$password);
- // Finalize user login (modify $_SESSION, set login time in db)
- user_login_finalize($arr); */
- $form_state = array();
- $form_state['uid'] = $user->uid;
- //$form_state['redirect'] = 'registration';
- user_login_submit(array(), $form_state);
- //$new_user = user_load_by_mail($user_name);
- }
- return theme('register', array('output' => $submission));
- }
- function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
- if ($form_id == 'webform_client_form_31') {
- $form['#submit'][] = 'my_submit_handler_for_registration';
- }
- }
- function my_submit_handler_for_registration(&$form, &$form_state) {
- $redirecting_to = variable_get("redirect_to");
- if($redirecting_to == "McKinsey Solutions") {
- $redirecting_to = "frontmso";
- }
- else {
- $redirecting_to = "";
- }
- $form_state['redirect'] = $redirecting_to;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement