Chain of Pain: Sending new user login info

For my new workshop I had to create 200+ accounts. It was enough that I wanted to do it programmatically, but not enough that I wanted to set up Migrate. I opted to use Feeds instead. That turned into a world of pain that went something like this:

  1. When importing new users with Feeds, there is no option to trigger the email for new accounts (that I could find). This means after you've created the accounts you still need to tell the account holders that they now have accounts on your site.
  2. The token/rules integration does not allow for one-time-login links to be used for new emails the same way that the core email for new users allows you to place a token for a one-time-login link.
  3. Even if VBO integration for One Time Login wasn't broken for Drupal 7, you'd still have to know your password to change your password ... so after clicking "send one time login" on 200+ accounts BY HAND would still receive 200+ email saying, "thanks for the login info, but I can't change my password without my password, can you email me my password?" (There may have been real live tears at this point...) Although someone told me that only admin users are supposed to be required to enter their password to change their password, I can't find a bug for this and I'm okay with the extra layer of security so I won't submit a bug for it.
  4. I don't think Quick Pass Reset ever claimed to have VBO integration, but you can click-to-edit everyone's account and resend a "reset password" email by hand.

That last option will save your bacon.

Although it's all done now, I think next time I'll just put on my big girl pants and use Migrate.

PS You're welcome to torture me in the comments with "what you should have done"s. ;)

Comments

i am not sure if this applies to your case but
i migrated drupal6 users to drupal7 by this code :
<?php
require_once DRUPAL_ROOT . '/includes/password.inc';
$new_pass = 'U' . user_hash_password($old_pass);
?>
and users where able to just use their old password .

if you are creating new accounts then you can generated the one
time login url manually using this function user_pass_reset_url, you just need to setup the @account parameter with arbitrary values .

and i don't think people need to know their old password, the one time login method is actually used in case a user forgot his/her password .

You were so close! Your answer is really already hidden in one of the links you posted.

All you need to do is activate the PHP module and add two lines of PHP to a conditional e-mail Rule. Just tried it myself, works beautifully!

I have pasted the Rule below, just import it and you are set to go.

{ "rules_send_one_time_login_email" : {
"LABEL" : "Send one time login e-mail",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "php" ],
"ON" : [ "user_insert" ],
"DO" : [
{ "mail" : {
"to" : "[account:mail]",
"subject" : "Your one time login link",
"message" : "Hi [account:name],\r\n\r\nHere is your link for a one time automatic login to our site:\r\n\r\n\u003c?php\r\n\r\n$onetimelogin = user_pass_reset_url($account);\r\nprint $onetimelogin;\r\n\r\n?\u003e"
}
}
]
}
}

Do not forget to deactivate the rule after your Feeds import - or add additional logic - otherwise the Rule-based e-mail will be sent to every new user.

I think it's great that you wrote about the experience. You'll be helping a lot of Drupal site owners in the future, and maybe some module developers will gain fresh insights on better ways to accomplish the objectives you had when you began.

You could also use drush to generate a one-time-login link via drush user-login username. The output will be the one-time-login URL which you could mail to the user with a short script.

Hi, I had a similar problem trying to import and sync users from an old Excel database for a non-profit website I built. I used User Import Framework, it was a life saver and allows for email on import. http://www.drupal.org/project/uif

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h2> <img>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.