I have been playing around with manipulating RedHen entities with rules. It seems like a couple of custom rules actions would help make pretty much every aspect of RedHen configurable with Rules.

This patch is a start. It gives you the ability to fetch the Redhen Contact from an account. More actions to come...

Comments

tauno’s picture

Would it make more sense for us to alter the user entity to add a 'contact' property with a getter callback that grabs the active contact for the user? Might help with modules other than rules as well.

nedjo’s picture

Title: Add additonal rules actions to reach_contact » Add rules integration for RedHen contacts

@tauno: while that could be useful, it won't cover all cases, as many contacts won't have corresponding user accounts.

@jlyon: thanks for the start! Some of what's needed could be modelled on the rules integration in redhen_engagement. What we're doing will in many cases be similar: responding to an action - e.g., anonymous login - that includes an email address that can therefore be related to or converted into a contact. Probably we should look first at generalizing what's in redhen_engagement.rules.inc. For example, the function redhen_engagement_rules_action_find_by_mail() should probably be moved into redhen_contact and renamed redhen_contact_load_by_mail().

nedjo’s picture

Title: Add rules integration for RedHen contacts » Enhance default rules integration for RedHen contacts

I guess actually the first step is to identify what Rules integration we want that isn't covered by default entity rules integration, or won't be once #1741568: Rules entity creation fails when creating RedHen Contact and any followup is completed.

Here are some suggestions of what we'll want:

Events

  • The basic CRUD operation events are probably adequately covered by default entity rules integration.

Conditions

  • Contact record exists by email. Testing this condition would allow us e.g. to skip the action of creating a new contact record if one already exists.

Actions

  • Fetch contact by email.
  • Fetch contact by user account. TBD: is a custom action needed? This may be a subset of Fetch contact by email, since the user account's email could be fed in as an argument, or it could be done with the regular Fetch entity by property action.
nedjo’s picture

Refreshed a relevant Rules patch: #1777204: Add condition "Entity exists by property".

jlyon’s picture

@nedjo: That list looks good. I would like to add one action: Create redhen_contact. The generic rules create entity doesn't let you select a bundle so is kind of useless for creating new contacts.

nedjo’s picture

@jlyon: Yes, creating a contact is one of the key missing pieces. That said, I think it's what #1741568: Rules entity creation fails when creating RedHen Contact is aiming at, so we shouldn't have to write a custom rules action for this. Looks like there's a new branch in #1741568 that can needs testing.

tauno’s picture

Status: Needs review » Needs work

The entity-metadata branch has been merged into 7.x-1.x now. Let us know if there are other properties you need in rules that don't work yet.

Another event that could be useful is when the contact - user linkage is updated. Not sure if it helps, but there's a hook for that (hook_redhen_contact_user_update).

We're not using rules heavily in our current RedHen projects, so it's great to see work being done on this.

levelos’s picture

Status: Needs work » Fixed

Due to lack of activity, I'll assume this was fixed with the entity metadata changes. Feel free to reopen if not.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.