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.
|1.12 KB||1.12 KB|
|1.28 KB||1.28 KB|
|1.04 KB||1.04 KB|
Just a couple of notes - if running on 4.2 you will need to be running a couple of patches. Not required on 4.3
( or you could just use our fuzion version of 4.2.8) git clone firstname.lastname@example.org:fuzionnz/civicrm.git , git checkout 4.2-d7
Nice solution Pete.
What about having your rule also delete the tag after creating the user?
not sure what to say. yes of course. i shall look in to it - or even a separate rule 'when user created remove tag xx if it exists' if doing so in the first rule interferes but i expect you are right and that it will do them in sequence.
this is a v. nice solution. I like the blog post calling attention to it as well. i also wonder if there is any way we can get better at collecting them somwhere. i guess the thing i am having trouble working out is what the classification would be / how we would make it easy for people to find this stuff.
seperately. we should have the first civicrm newsletter (via civimail) coming out pretty soon - it would be nice to highlight it that as well.
this comment is just to check pete's new notifications
good work pete
Hey thanks for this, it really saved me so much hassle!
I was wondering, though... Right now the Drupal account usernames that are created are the display named of the contacts, which are formatted with spaces and makes it somewhat awkward. Is there a way to assign a username?
It would probably have to come from a custom field created by an admin upon creation of the contact, unless it were possible to format it automatically somehow... Maybe the user can create it upon signup? Hm.
Looks like a fantastic solution. In trying to test it out, I found that the attachment links are triggering an Nginx 403 error. Would be appreciative of a fix or altenative link.
crew are looking in to permissions - try again in a day or so
seems to be working now for .txt files
Hello, I am trying this solution with CiviCRM 4.4.3 and Drupal 7.26. I recive an error at <code>admin/config/workflow/rules/reaction/import</code>
that will not allow me to import the rule. Can anyone help with this? Error: <code>
Integrity check for the imported configuration failed. Error message: Missing configuration for parameter <em class="placeholder">signin</em>..
Thank you, --Tony
Hi Tony - I haven't upgraded that site from 4.2.10 yet so thanks for the warning. We expect to do a round of upgrades when 4.4.4 comes out later this week.
may have nothing to do with 4.4 though so will attach the latest
Did you link to the wrong file for the standard rule attachment? It has "rules_friends_tag_account_create" and requires Domain Rules module.
I can see what looks like the correct file at http://civicrm.org/sites/civicrm.org/files/Create%20User%20via%20Tag%20Rule.txt but is it the updated version?
Plus, I get:
Integrity check for the imported configuration failed. Error message: Missing configuration for parameter <em class="placeholder">signin</em>
when trying to imort the rule
Hi Clive - yes there is something amiss with those files that I need to tidy up - sorry about that.
Also there have been variations to deal with whether we want the user to be logged in directly (and be sent a 'you created and account' type email) or sent an 'Admin has created you an account' type email.
See how you go with the one I just added https://civicrm.org/sites/civicrm.org/files/Create%20User%20Account%20with%20login%20option.txt
Wow! Thanks for that responsive reply. I really didn't expect to get an answer so quickly.
I imported the "rules_entity_tag_account_create" version and everything worked for importing contacts. The only thing is, I would prefer that the 'Admin has created you an account' version of the email went out. I tried to edit the rules to see if there was any option for that, but it looks like its defined by $notify in the civicrm_entity module code. I guess there is no way to change that without altering the module?
Thanks again Pete.
will try and have a look at it before end of week
(scratches head - why do your 'comments' need approving!)
I am getting the error
Integrity check for the imported configuration failed. Error message: Unknown action <em class="placeholder">civicrm_entity_action_create_user</em>..
Am i missing a step before importing the rule?
i don't know - you haven't said what steps you took ;-)
did you install civicrm_entity?
what version civicrm are you using?
I am using civi 4.4.3 and i already have civicrm_entity installed from other project but it was this version (https://www.drupal.org/project/civicrm_entity) - I was trying to import the rule at yoursite>/admin/config/workflow/rules/reaction/import - but got that error message. I tried all rule versions posted above and none of them worked.
ok - will try and take a look tomorrow
did you ever get a chance to look at this. cant get it to work with latest version of civicrm entity module
Hi Mike - can you be a bit more specific on what the 'it' is. I know we have this running fine on several 4.6.x sites but since there are several 'its' involved, i want to be sure I am being helpful by focussing on the right part.
I have the following message when I activate Domain Access and Domain Rules :
- Domain module installation is incomplete. See INSTALL.txt and check your settings.php file.
- Domain access failed to load during phase: bootstrap include. Please check your settings.php file and site configuration.
Where is this INSTALL.txt file ?
What should I check in settings.php file ?
Is this on a site that is using Domain?
Hi Tony, Do you have the latest CiviCRM Entity module enabled? What version of civicrm?
I am on Drupal 7.59, CiviCRM 7.x-5.3.0, CiviCRM Entity 7.x-2.1, Rules 7.x-2.11.
better to continue the discussion in stackexchange
Thanks very much for this write-up.
I could not get it to work in Drupal 8, as the required Element is not available in Rules for Drupal 8. Do you have any advice on how to implement this functionality in Drupal 8?
The user_format seems to be needed now. I had to add the following to the import script to import properly:
Paste this just below the signin definition.
(Also added in StackExchange)