function hosting_client_register_user in Hosting 6.2
Same name and namespace in other branches
- 5 client/hosting_client.module \hosting_client_register_user()
- 7.4 client/hosting_client.module \hosting_client_register_user()
- 7.3 client/hosting_client.module \hosting_client_register_user()
Register a new user account for the client.
This is a helper function for client forms that will create a user alongside a new client if the hosting_client_register_user setting is true.
See also
1 call to hosting_client_register_user()
- hosting_client_insert in client/
hosting_client.module - Implementation of hook_insert().
4 string references to 'hosting_client_register_user'
- hosting_client_configure in client/
hosting_client.module - Menu callback for the module's settings.
- hosting_client_form in client/
hosting_client.module - Implementation of hook_form().
- hosting_client_insert in client/
hosting_client.module - Implementation of hook_insert().
- hosting_signup_form in signup/
hosting_signup.module - Form definition
File
- client/
hosting_client.module, line 345
Code
function hosting_client_register_user($node) {
$pass = user_password();
$user = new stdClass();
$edit['name'] = $node->uname;
$edit['hosting_client'] = $node->nid;
$edit['mail'] = $node->email;
$edit['pass'] = $pass;
$edit['status'] = 1;
$edit['roles'][_hosting_client_get_role()] = TRUE;
$user = user_save($user, $edit);
if ($user->uid && variable_get('hosting_client_send_welcome', FALSE)) {
if ($node->client_name) {
$to = sprintf("%s <%s>", $node->client_name, $node->email);
}
else {
$to = $node->email;
}
$params = array(
'!username' => $user->name,
'!site' => variable_get('site_name', 'Drupal'),
'!password' => $pass,
'!uri' => $GLOBALS['base_url'],
'!uri_brief' => substr($base_url, strlen('http://')),
'!date' => format_date(time()),
'!login_uri' => url('user', array(
'absolute' => TRUE,
)),
'!edit_uri' => url('user/' . $user->uid . '/edit', array(
'absolute' => TRUE,
)),
'!login_url' => user_pass_reset_url($user),
);
// No e-mail verification is required, create new user account, and login user immediately.
$language = user_preferred_language($user);
drupal_mail('hosting_client', 'hosting-client-register-welcome', $to, $language, $params);
}
return $user;
}