Creating Drupal users made easy: for single or multiple Contacts, via Civi imports and via Webforms
After several dead ends I think we have something that is useful to share - just add a Tag - not as useful as having it as an Action after Adv Search perhaps - but with other possibilities that I like.
We repeatedly hit the problem of needing to create Drupal Users for civicrm contacts. While we have used the User Import module in D6 and D7 it required a bunch of steps that we wanted to sidestep. And while the Action for an Individual Contact is useful, it does not do the whole Drupal thing of sending out the 'you have an account' email.
Using Rules in Drupal was the way we have been exploring. Originally I wanted to do it via Activity but we hit the issue that we weren't getting it to apply to the Target, rather than the Assignee - and now I see that even if we had, it would have cut off another option.
We tried via Groups - to much inconsistency says Eileen. We could have gone via Custom Fields, but wanted to make this easily shared.
So the outcome is a Rule that creates a Drupal user and fires out the welcome email whenever a Contact is tagged with (Tag ID = whatever you specify) - in our case the tag is called 'create Drupal account'
After various gotchas - how it handles dealing with multiple contacts, or on multisites with different Drupal tables - I can finally report that it works when tagging a new contact at first point of creating (eg New Individual), as well as when tagging one or more contacts (eg after Search). Cool.
But wait I thought, will it also work when doing a CiviCRM Import of contacts - well yes it does. Nice!
And what about if I tag contacts when creating them via a Webform (another source of frustration that we had tried directly via Rules, but were hitting the problem that the Drupal User was creating a duplicate civi contact) - again yes. And a bonus for us at least - having not gone down the Activity route leaves us free to create a different Activity via the Webform-CiviCRM if required.
Only downside at this point is we end up with people having a Tag that we have no use for (the tag, not the contacts) - but a Smart Group that we de-tag occassionaly can take care of that for now.
What do you need to try this out?
Grab CiviCRM Entity from https://github.com/eileenmcnaughton/civicrm_entity
Grab the attached Rule and import at <yoursite>/admin/config/workflow/rules/reaction/import
Then modify "Data Comparison: Parameter: Data to compare: [civicrm-entity-tag:tag-id] to be the ID of the Tag you want to use.
eg at path <yoursite>/admin/config/workflow/rules/reaction/manage/rules_entity_tag_account_create
Found that we needed an extra Action in the rule to ensure the Domain is assigned to users otherwise then end up Blocked - and this requires the Domain Rules module. Rule attached below.
(see images below)
Let us know how you get on.
|Rule for creating users via Civi Tag - standard||938 bytes|
|Rule for creating users via Civi Tag - Domain sites||1.12 KB|