You are here

function field_user_import_after_save in User Import 7.2

Same name and namespace in other branches
  1. 8 supported/field.inc \field_user_import_after_save()
  2. 7.3 supported/field.inc \field_user_import_after_save()
  3. 7 supported/field.inc \field_user_import_after_save()

Implementation of hook_user_import_after_save().

File

supported/field.inc, line 41

Code

function field_user_import_after_save($settings, $account, $password, $fields, $updated, $update_setting_per_module) {
  $fields_data = isset($fields['field']) ? $fields['field'] : array();
  if (empty($fields_data)) {
    return;
  }
  $processors = field_user_import_supported_fields();
  $delimiter = $settings['multi_value_delimiter'];
  $user_fields = user_load($account->uid);
  $processed_fields = array();
  foreach ($fields_data as $field_name => $data) {
    $field_info = field_info_field($field_name);
    $field_type = $field_info['type'];
    $processor_function = $processors[$field_type]['save'];

    // Deal with multiple values.
    $values = explode($delimiter, $data[0]);

    // Use callback function to process info for field before saving.
    $processed_fields[$field_name] = $processor_function($user_fields, $field_name, $values);
  }
  if (!empty($processed_fields)) {
    user_save($account, $processed_fields);
  }
  return;
}