0
votes

I have a site which has users in two categories - A and B.

I have a CSV file of usernames, email addresses and new passwords for all users in Category A (category B isn't to be affected)

How can I import this CSV to change the passwords?

What I've tried: Feeds Import - Errors out with "The website encountered an unexpected error. Please try again later." - no clues in Drupal.

User Import - I configure it to update user passwords, but it creates new users with the same usernames as existing ones, suffixed with '2'.

There are over 500 usernames to be updated, so cut-n-paste isn't going to be an option.

All ideas accepted!

2
Read the csv file line by line and create / update users programaticallyViswanath Polaki

2 Answers

0
votes

Based on your description, it sounds like you might be missing the UID for each user account. Your feed import should be an update records with existing UID as opposed to the standard feed import behavior of creating new data records (in this case, it may be trying to create new user accounts rather than update existing ones- but since you can only have one account per email, it would fail to import on all the users in the list)

If the feeds import still bombs after adding the UID column and mapping the feed to update corresponding user data, it could be a result of the server just timing out. Recommend you check the server logs to see if it timed out or hit a memory limit.

Otherwise, you should be able to use the Feeds module to import your csv. Check out https://www.isovera.com/blog/using-feeds-module-bulk-import-drupal-7 for a general rundown of importing a csv with feeds.

Before importing, you'll also want to make sure the passwords are properly hashed. refer to https://www.drupal.org/node/1058316 which would put you on track to hash plain text with a simple php function.

0
votes

Just an update on how I ended up doing this task;

I used the drush command upwd (update password)

drush upwd --password={newpassword} {existingusername}

I built the unique drush commands in a column on the spreadsheet, then pasted them into an SSH command line.

Extensible? No. Reusable? Not very. Effective? Yes. And time/cost-effective.