Simple Rule Example Using CiviCRM Entity
he new Drupal module CiviCRM Entity exposes 11 CiviCRM objects as Drupal Entities and provides rules support for these entities. In this article I will demonstrate how to create a simple rule, which creates a synced Drupal user for the contact when the contact gets a membership.
This how-to assumes you have the Rules module and the CiviCRM Entity module installed.
Create the rule:
- For name enter "Create Synced User When Contact Gets Membership"
- For React on Event: Select "CiviCRM Membership has been created"
- Click Save
- Under Actions select "Create Linked Drupal User Account"
- Click Continue.
- The default value for the CiviCRM contact Contact Data selector field should already be correct,but ensure it is: "civicrm-membership:contact-id-contact".
- Check Activate account and Send account notification email if you wish.
- Click Save.
You can extend the rule
If you would like to only create the user for a specific membership type.
- Under Conditions click the Add Condition link
- For the Select the condition to add field select Data Comparison
- Under Data to Compare use the data selector find the membership type id field of the membership object. It should be this: "civicrm-membership:membership-type-id".
- Click Continue
- Under Operator select Equals
- Under Data Value enter the membership type id of the membership type you'd like to create linked Drupal users for.
- click Save