Body: <p>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.</p>
  
  <p>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)</p>
  
  <p>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.</p>
  
  <p>Any existing modules or code examples?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-12T23:02:24.263Z
Comments.Text: Have you had a look at what Drupal rules offers - not sure the status of that for d8
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-14T02:15:04.187Z
Comments.Text: 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.
Comments.UserDisplayName: theta-fish
Tags: <drupal><relationships><roles>
Title: Module to Sync CiviCRM Organization's Related Contacts to Drupal8 Roles?
ThreadText: # Module to Sync CiviCRM Organization's Related Contacts to Drupal8 Roles?
  
  (Asked by: username_0 on 2018-07-12)
  
  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?
  
  **Tags:** drupal, relationships, roles
  
  > **Comments:**
  > **username_1**: Have you had a look at what Drupal rules offers - not sure the status of that for d8  
  > **username_0**: 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.  
  
  ---
  
  ## 0 answers
  
  