How To Create Users Programmatically In Drupal 6.x

Michael Phipps's picture

Here's a quick code snippet you can use to programmatically create new users in Drupal 6.x:

  'pass' => 'password', // note: do not md5 the password
  'mail' => 'email address',
  'status' => 1,
  'init' => 'email address'
user_save(null, $newUser);

And, here's how you can update an existing user:

some_property = 'blah';

// save existing user
user_save((object) array('uid' => $existingUser->uid), (array) $existingUser);
© 2010 Your Name.. Drupal theme by Kiwi Themes.