You are here

function profile2_form_submit_handler in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_form_submit_handler()

Submit handler that builds and saves all profiles in the form.

See also

profile2_attach_form()

1 string reference to 'profile2_form_submit_handler'
profile2_attach_form in ./profile2.module
Attaches the profile forms of the profiles set in $form_state['profiles'].

File

./profile2.module, line 683
Support for configurable user profiles.

Code

function profile2_form_submit_handler(&$form, &$form_state) {
  profile2_form_submit_build_profile($form, $form_state);

  // This is needed as some submit callbacks like user_register_submit() rely on
  // clean form values.
  profile2_form_submit_cleanup($form, $form_state);
  foreach ($form_state['profiles'] as $type => $profile) {

    // During registration set the uid field of the newly created user.
    if (empty($profile->uid) && isset($form_state['user']->uid)) {
      $profile->uid = $form_state['user']->uid;
    }
    profile2_save($profile);
  }
}