Revision: 64201
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 13, 2013 02:59 by pictonio
Initial Code
/**
*
* Criar nova conta
*
* @param $email
* @return bool
*/
function _create_user_account($email) {
//This will generate a random password, you could set your own here
$password = user_password(8);
//set up the user fields. In this case username = mail.
$fields = array(
'name' => $email,
'mail' => $email,
'pass' => $password,
'status' => 1,
'init' => 'email address',
'roles' => array(
DRUPAL_AUTHENTICATED_RID => 'authenticated user',
),
);
//the first parameter is left blank so a new user is created
$account = user_save('', $fields);
if(!empty($account)) {
// Manually set the password so it appears in the e-mail.
$account->password = $fields['pass'];
// Send the e-mail through the user module.
drupal_mail('user', 'register_no_approval_required', $email, NULL, array('account' => $account), variable_get('site_mail', '[email protected]'));
return TRUE;
}
else {
return FALSE;
}
}
Initial URL
Initial Description
Create new user account programmatically - drupal 7
Initial Title
Create New Account
Initial Tags
drupal
Initial Language
PHP