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 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

By gkornbluth - February 6, 2013 - edited: February 6, 2013

Hi Greg.

Just thought it might be helpful. I played around tonight, and it seems that the imported passwords were automatically  encrypted.

I’m using V2.17 because my server is not up to the 2.50 requirements for PHP and MySQL

Before I imported the CSV file, I duplicated the entire password column and renamed it visible_password. Then, in the accounts database I created a text field called visible_password as well as the last_name and first_name text fields.

When I imported the CSV file, after I accessed it the second time, the password field was encrypted, but the username and visible_password combination allowed me to log in to the interface. As a reminder I can send the username and visible_password value to all of the current account holders.

Hope that helps someone.

Best,

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,

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