Using CSV import to create records in the User Accounts database

Hi All,

I’m planning to use the CSV Import plugin (for the first time) to import a number of new users to an existing user accounts database.

I have a CSV file with the following columns, which match existing fields in the database.

last_name, first_name, email, username, password, disabled, isAdmin, neverExpires

Can anyone who has done this before tell me if there are any other columns that will be required for the records to be valid in the accounts database?

Any other suggestions?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry,

It looks like you've got all of the correct fields covered.

The only problem your going to have is that passwords will not be encrypted by the import plugin, and this will stop the imported users from logging in. Are these users for the front end of the site? As you could get them to use the e-mail password reset system to create there own password the first time they log in. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Greg,

Is there a way to encrypt the passwords on (or after) import? There are quite a few, they'll be using passwords that they used on an old access system, and I'd like to make this as seamless as possible.

Thanks,

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry, 

There are a couple of options you could try:

You could encrypt the passwords in the CSV file before you import them. You could create a simple PHP script that opens a CSV file and puts its data into an array using fgetcsv, then loop through the array and use the getPasswordDigest function to encrypt the passwords. The final step is to use fputcsv to save the updated array to a CSV file. 

The second slightly simpler option is to use the mysql_select function to get all of the records from the accounts section and loop through them using foreach, then using the getPasswordDigest function to encrypt each password. Finally you could use the mysql_update function to save the encrypted passwords to each record. But you'd have to be very careful not to encrypt passwords that where already encrypted. You could do this by adding a encrypted check box to the section, and checking it against all the records that already exist, and only selecting records that don't have it checked when using the mysql_select function.

We would be able to create this script for you if needed. If you send an e-mail to consulting@interactivetools.com we can give you an estimate of the cost.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Jerry,

Thanks for the feedback, that is useful to know. I'll keep this in mind in the future.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com