How to create a user programmatically in drupal5 (simple version without profile fields)

Posted by: 
Dominique De Cooman

function create_users() {
  $username = 'your_username';                  
  $password = 'your_password';
  $contact = 0;//set to 1 to enable the users personal contact form
  $email = '<a href=""></a>'
  //optional: create a role and fill in the $rid
  //$roles[$rid] = 'your_role'; 
    $account = array(
    'name' => $username,
    'pass' => $password,
    'mail' => $email,
    'init' => $email,
    'timezone' => '-18000',
    'status' => 1,
    'roles' => $roles,
    'contact' => $contact
  $account['access'] = time();
  $account['login'] = time();
  $account = user_save('', $account);             

Add new comment

Who are you?

By knowing who you are you will be directed to a page where we have displayed all our drupal services relevant to your professional identity.