When someone submits a CiviCRM-enabled Webform, can I create a Drupal user for them automatically?
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
- CiviCRM Entity
- Create a tag within CiviCRM, something like "Create Drupal User".
- Set up the form, enable CiviCRM processing, and add a contact in the CiviCRM tab, customizing as you see fit.
- On the "Tags and Groups" section for this contact, select the tag you created in #1.
- Go to the Rules page (Configuration > Workflow > Rules) and click "Add New Rule"
- Name the rule and choose the React on Event as "CiviCRM Entity Tag has been created"
- 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
- Then we do a data comparison on
civicrm-entity-tag:entity-tableto make sure that it is "civicrm_contact" (to be sure we are updating the right entity)
- 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-idequals this numeric ID.
- 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.
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)