By Jacobtv on
Hi.
Is there any way to either mass import multiple users, or create multiple users through the database?
I really want to avoid having to create one user at the time through the administration, but I don't know that much about programming. I am using Drupal 6.2
Regards
Jacob
Comments
It's quite easy (if you know
It's quite easy (if you know a little php)
user_save is the drupal function that you'll need.
user_save takes a few parameters http://api.drupal.org/api/function/user_save/6
user_save($account, $array = array(), $category = 'account') {
I've imported over 200,000 users with a simple script didn't take more than a few minutes to run through it either. The users were originally in a CSV file.
Arhhh...
That sounds exiting. Do you have a more detailed instructions? As I said, I don't know php, so I would really appreciate all the help I can get.
The best would of course be the users import module, but that hasn't been adapted to Drupal 6.x yet :-(
RE:Importing multiple users?
Jacob,
I am considering the same issue. I have mysql and MS access successfully linked (which appears to be a potential solution for mass import) but depending upon the difficulty of tweaking the php code in the user module I may want to do it the same way as you have proposed. Have you changed the user module yet, and if so what parameters need to be changed or modified?
Thanks
There's no need to change
There's no need to change the users module
All you need to do is create a simple module of your own that loads your users into an array.
Then work through the array and call the user_save function for each user that you've got in your array.
user_save is well documented here: http://api.drupal.org/api/function/user_save/6 for drupal 6 or here http://api.drupal.org/api/function/user_save/5 for drupal 5
user_save is well documented?
I wouldn't say "well documented" for much of anything in the API reference. For instance, what exactly are the values that can and/or should be in the array? "name" is obvious, but there are permissions and many other possible fields, I suspect.
Since I am hoping to use "user_save" to migrate registration from another system upon page load (using a hook_menu perhaps?), I'm going to need to know them all, and which ones are critical, though of course most can be gleaned by just looking at the "add user" form...