function user_user_import_pre_save in User Import 8
Same name and namespace in other branches
- 5.2 supported/user.inc \user_user_import_pre_save()
- 5 supported/user.inc \user_user_import_pre_save()
- 6.4 supported/user.inc \user_user_import_pre_save()
- 6.2 supported/user.inc \user_user_import_pre_save()
- 7.3 supported/user.inc \user_user_import_pre_save()
- 7 supported/user.inc \user_user_import_pre_save()
- 7.2 supported/user.inc \user_user_import_pre_save()
Implementation of hook_user_import_pre_save().
File
- supported/
user.inc, line 102
Code
function user_user_import_pre_save($settings, $account, $fields, $errors, $update_setting_per_module) {
$account_add['mail'] = $fields['user']['email'][0];
if (!empty($account['uid'])) {
// update roles
switch ($update_setting_per_module['roles']) {
case UPDATE_ADD:
// include currently assigned roles
foreach ($account['roles'] as $rid => $role_name) {
$account_add['roles'][$rid] = $rid;
}
case UPDATE_REPLACE:
// update roles
if (!isset($account_add['roles'])) {
$account_add['roles'] = array();
}
foreach ($settings['roles'] as $rid => $role_set) {
if (!empty($role_set)) {
$account_add['roles'][$rid] = $rid;
}
}
break;
}
// update password
if ($update_setting_per_module['password'] == UPDATE_REPLACE) {
$account_add['pass'] = empty($fields['user']['password'][0]) ? user_password() : $fields['user']['password'][0];
}
else {
$account_add['pass'] = "";
}
// update contact
if ($update_setting_per_module['contact'] == UPDATE_REPLACE) {
$account_add['contact'] = $settings['contact'];
}
else {
$account_add['contact'] = isset($account['contact']) ? $account['contact'] : '';
}
}
else {
$account_add['timezone'] = '-18000';
$account_add['status'] = 1;
$account_add['init'] = $fields['user']['email'][0];
$account_add['pass'] = empty($fields['user']['password'][0]) ? user_password() : $fields['user']['password'][0];
if (isset($fields['user']['created'][0]) && !empty($fields['user']['created'][0])) {
$account_add['created'] = $fields['user']['created'][0];
}
$account_add['init'] = $fields['user']['email'][0];
if (!empty($settings['options']['activate'])) {
$account_add['access'] = time();
$account_add['login'] = time();
}
// add selected roles
foreach ($settings['roles'] as $rid => $role_set) {
if (!empty($role_set)) {
$account_add['roles'][$rid] = $rid;
}
}
}
return $account_add;
}