Batch migration of users into Drupal

The $new_user array can contain any field with the name matching a field in the "users" database table.
$new_user = array(
'name' => $username,
'pass' => $password,
'mail' => $email,
'status' => true,
);
"mail" can be omitted, but the important one is the username.
Once the data is filled, call user_save() to create the user.
$new_user_object = user_save(NULL, $new_user);
The important part is to give the first parameter NULL, as we want to be creating new users.

Be sure to check "$new_user_object afterwards != FALSE" in case the registration process failed.

This code was checked and working with Drupal 6.x.
 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog