You are here

function party_user_form_user_submit in Party 7

Same name and namespace in other branches
  1. 8.2 modules/party_user/party_user.module \party_user_form_user_submit()

Submit the user data set form

File

modules/party_user/party_user.module, line 152
Support for linking users to parties

Code

function party_user_form_user_submit($element, &$form_state, $data_set, $delta, $party) {
  $account = $data_set
    ->getEntity($delta);
  $account_unchanged = clone $account;
  $category = $element['#user_category'];
  $values = drupal_array_get_nested_value($form_state['values'], $element['#parents']);

  // This code is taken out of entity_form_submit_build_entity
  // Flatten the $form_state values for the user.
  $account_values = array();
  $account_values += isset($values['account']) ? $values['account'] : array();
  $account_values += isset($values['signature_settings']) ? $values['signature_settings'] : array();
  $account_values += isset($values['picture']) ? $values['picture'] : array();
  $values_excluding_fields = array_diff_key($account_values, field_info_instances('user', 'user'));
  foreach ($values_excluding_fields as $key => $value) {
    $account->{$key} = $value;
  }
  field_attach_submit('user', $account, $element, $form_state);
  $edit = array_intersect_key((array) $account, $account_values);
  user_save($account_unchanged, $edit, $category);
}