By: Michael Phipps
8 Nov 2009Here's a quick code snippet you can use to programmatically create new users in Drupal 6.x:
<?php $newUser = array( 'name' => 'username', '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:
<?php
// load user object
$existingUser = user_load('USERID');
// update some user property
$existingUser->some_property = 'blah';
// save existing user
user_save((object) array('uid' => $existingUser->uid), (array) $existingUser);
?>