6

When someone submits a CiviCRM-enabled Webform, can I create a Drupal user for them automatically?

11

This conversation came up on the CiviCRM chat. I have done this for a site previously -- following instructions from @petednz's blog post here. (Note that blog post also has some exported Rules that you can download to start with and maybe save some time).

But if you want to start from scratch, here's what you need:

  • Webform CiviCRM
  • Rules
  • CiviCRM Entity

  1. Create a tag within CiviCRM, something like "Create Drupal User".
  2. Set up the form, enable CiviCRM processing, and add a contact in the CiviCRM tab, customizing as you see fit.
  3. On the "Tags and Groups" section for this contact, select the tag you created in #1. Tags and groups
  4. Go to the Rules page (Configuration > Workflow > Rules) and click "Add New Rule"
  5. Name the rule and choose the React on Event as "CiviCRM Entity Tag has been created" React on event
  6. As for Conditions, we first want to make sure there is no existing Drupal user for this contact, so we use the "Drupal User Account exists for Contact" and negate it (data selector value will be something like civicrm-entity-tag:entity-id-contact).
  7. Then we do a data comparison on civicrm-entity-tag:entity-table to make sure that it is "civicrm_contact" (to be sure we are updating the right entity)
  8. And as the final condition, another data comparison to make sure the tag that was created is the correct tag which should result in a Drupal user being created. Using the numeric tag ID from the tag you created in #1 (you can find this in the second column of the CiviCRM "Manage tags" section), we can compare to make sure that civicrm-entity-tag:tag-id equals this numeric ID. Conditions
  9. Finally, under Actions, we can use the "Create Linked Drupal User Account" action on the data selector civicrm-entity-tag:entity-id-contact. There are a few other options within here which you can set related to whether to activate/auto-sign in/send notification email as well.
  • I am trying to follow the procedure outlined above but when I try to add the Event to the Rule described, the 'CiviCRM Entity Tag' does not appear in the list of possible triggers. I must be missing some module or configuration option, but can't see it. Any help welcome, Thanks, Tony – maynardsmith Jul 23 '18 at 18:28
  • Tony - I converted your 'Answer' to a Comment (stackexchange is Q&A, not a forum). If you can clarify which steps of Laryn's you tried and what version of CiviCRM Entity you have enabled – petednz - fuzion Jul 23 '18 at 19:15
  • @maynardsmith Do you have the CiviCRM Entity module installed and activated? drupal.org/project/civicrm_entity – Laryn - CEDC.org Jul 24 '18 at 20:08
3

The blog here, which may have been the source of Laryn's solution, also contained some exported Rules that might still work out of the box. There are variations depending on whether you want to log the person in immediately the form is submitted (which we often do when the webform is the second in a chain of webforms)

  • Yes, that was it -- I just updated to give credit to you. And thanks, it is a brilliant strategy! – Laryn - CEDC.org May 12 '16 at 0:06
  • cool - will up your answer since it is the more complete. – petednz - fuzion May 12 '16 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.