Is there an existing module or technique to sync Civi contacts and Drupal8 roles based on their relationships to a Civi Organization? Assume the contacts have linked Drupal user accounts.

There appear to be modules for syncing Memberships to Drupal roles (civicrm_member_roles) or to static Civi Groups to Drupal Roles (civicrm_group_roles), but I can't find a corresponding "civicrm_related_contacts_roles" module. (I'm aware that these modules were designed for Drupal7, but I've been able to fit the membership sync module to an existing Drupal8 installation, so I'm hoping the same is possible if a module exists for relationships)

Ideally, such a module would let me specify a Civi Contact (I guess we can ignore whether it's an Org, Ind, or Household), a Civi relationship type that an Individual might be able to have with that Contact, and a Drupal role. Then anyone who is related in that way to that Contact would automatically be assigned to the Drupal role.

Any existing modules or code examples?

  • Have you had a look at what Drupal rules offers - not sure the status of that for d8 – petednz - fuzion Jul 12 '18 at 23:02
  • D8 rules is in prerelease/alpha right now. I came across a blog post on doing something similar to what I’m attempting via rules in D7, but I suspect that Civi won’t be compatible enough yet to work. I found a way to just hack the sync for my purposes using a module hook, custom sql, and the Accounts api. I plan to revisit this later and see if I can get a more robust version working. Will report back here if I can pull it off. Or perhaps someone will suggest something better here. – theta-fish Jul 14 '18 at 2:15

Your Answer

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

Browse other questions tagged or ask your own question.