function uif_create_user in User Import Framework 7
Same name and namespace in other branches
- 6 uif.admin.inc \uif_create_user()
Create a new user.
1 call to uif_create_user()
- uif_import_user in ./
uif.admin.inc - Import one user.
File
- ./
uif.admin.inc, line 505 - Simple, extensible user import from a CSV file.
Code
function uif_create_user($user_data, $notify, $form_state) {
$account = array();
$account['mail'] = $user_data['mail'];
$account['init'] = $user_data['mail'];
$account['status'] = 1;
// Use the provided username if any, or derive it from the email
$username = empty($user_data['name']) ? preg_replace('/@.*$/', '', $user_data['mail']) : $user_data['name'];
$account['name'] = uif_unique_username($username);
// Use the provided password if any, otherwise a random one
$pass = empty($user_data['pass']) ? user_password() : $user_data['pass'];
$account['pass'] = $pass;
// Add roles if present
if (isset($user_data['roles'])) {
$account['roles'] = uif_parse_roles($user_data['roles']);
}
$account = array_merge($account, module_invoke_all('uif_pre_create', $account, $user_data, $form_state));
$account = user_save('', $account);
module_invoke_all('uif_post_create', $account, $user_data, $form_state);
if ($notify) {
$account->password = $pass;
// For mail token; _user_mail_notify() expects this
_user_mail_notify('register_admin_created', $account);
}
return $account;
}