Simple Rule Example Using CiviCRM Entity

The 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 modules and the CiviCRM Entity module installed.

Create the rule:

  • admin/config/workflow/rules/reaction/add
  • 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 ccount 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




Block Drupal User when Membership Expires

Your steps worked perfectly for me in creating a Drupal account upon a new CiviCRM membership. I tried to create a rule to block the exiting Drupal account when the membership has been deleted with the following entries:Event: CiviCRM Membership has been deletedActions: Block a UserData Selector: civicrm-membership:contact-id-contact:civi-userThis does not seem to work. The Drupal user remains active after deleting the membership in CiviCRM.Any tips would be appreciated.

Rules CiviEntity Action Data Issues

Mark,I'm trying to create a new CiviGroup of the same name when a new Organic Group is created.Not sure what I'm mssing, but the Parameter/Variable bit is thoroughly confusing.  How do I get the current OG Group Name and pass it along to the action? Any help would be greatly appriciated. A full example would be great :D  If I can get this working I'll write the example steps up for you to post.Event:

  • After saving new content of type [OG group type]

Conditions: none (right now)Actions:

  • Create a new entity
    • Parameter: Entity type: CiviCRM civicrm_group
    • Provides variables: Title (title)

 adding a new og group sptis this out:Error messageException: Mandatory key(s) missing from params array: title in CivicrmEntityController->save() 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.