Answers.Body: <p>I'm not sure what "Groups Role Sync" is (I suspect it's a Drupal module) but you can use <a href="https://wordpress.org/plugins/civicrm-wp-member-sync/" rel="nofollow noreferrer">CiviCRM WordPress Member Sync</a> to sync Contacts with Memberships to WordPress Users with Roles or Capabilities. FWIW, the plugin doesn't support Smart Groups either.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-30T11:40:32.907Z
Answers.Text: Thanks @christian but we need to specifcally support smart groups. This is the plugin for WordPress to do Group Role sync: https://develop.tadpole.cc/plugins/civicrm-groups-sync
Answers.UserDisplayName: Darren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-31T10:14:00.437Z
Answers.Text: @Darren That plugin doesn't support smart groups either.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-31T10:18:15.237Z
Answers.Text: Perhaps you can explain why you need the sync to be on the basis of a Smart Group?
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-01T14:02:20.163Z
Answers.Text: To clarify - Smart Groups cannot be of type "Access Control", so they shouldn't really be used for that purpose.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-02T08:53:49.850Z
Answers.Text: We don't neccesarily need to use Smart Groups, but there doesn't seem to be another way to add a capability automatically based on data held in Civi?
Answers.UserDisplayName: Darren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-02T15:21:20.937Z
Answers.Text: @Darren Both of the plugins we're discussing grant capabilities to WordPress Users depending on what happens in CiviCRM - CWMS bases this on a Contact's Membership status whilst CGS does this on the basis of a Contact's Group Membership. Perhaps you can edit your question to explain what circumstances should cause a WordPress User (synced to a Contact) to be granted a capability?
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-03T11:08:15.093Z
Answers.Text: Hi @Christian I've explained the requirement above. Hopefully this clarifies what we're trying to do.
Answers.UserDisplayName: Darren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-03T15:26:09.070Z
Answers.Text: @Darren Ah, I see - thanks. Will email you my thoughts and update the answer here when we reach a sensible conclusion
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-30T10:34:34.293Z
Answers.LastActivityDate: 2020-03-30T10:34:34.293Z
Answers.UserDisplayName: Christian Wach
Body: <p><strong>* EDIT *</strong> We have a multi record custom data group with a field called "Status". When this field changes value to "Completed" we want people to see specific pages in WordPress.</p>
  
  <p>I have tried to setup a Smart Group and link this to a Role in Civi using Groups Role Sync, but this plugin does not work with smart groups. </p>
  
  <p>I created a Parent ACL group of the smart group in question, but this is not being populated. </p>
  
  <p>I've also tried creating a CiviRule to add a membership when custom fields are edited and then use the membership sync to role plugin, but CiviRules can't evaluate the values in multi record custom data groups (for understandable reasons).</p>
  
  <p>So.... I was wondering if anyone had any other ideas of how we can automatically add a capability or role in WordPress based on the data in CiviCRM? Maybe someone could share some custom code for a plugin to do this, <a href="https://civicrm.stackexchange.com/questions/17710/syncing-drupal-roles-from-civicrm-smart-groups/19523#19523">similair to this answer</a> but for WordPress?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-03-30T11:40:55.913Z
Comments.Text: This is the Group Role Sync plugin for WordPress: https://develop.tadpole.cc/plugins/civicrm-groups-sync
Comments.UserDisplayName: Darren
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-26T22:13:40.567Z
Comments.Text: One way to sidestep Smart Groups is to instead add folk to a Group via CiviRules if the 'trigger' of why someone should be in the group can be easily defined
Comments.UserDisplayName: petednz - fuzion
Tags: <wordpress><smartgroups><roles>
Title: How can I automatically add a Capability or additional Role in WordPress based on the data stored in CiviCRM?
ThreadText: # How can I automatically add a Capability or additional Role in WordPress based on the data stored in CiviCRM?
  
  (Asked by: username_0 on 2020-03-30)
  
  **\* EDIT \*** We have a multi record custom data group with a field called "Status". When this field changes value to "Completed" we want people to see specific pages in WordPress.
  
  I have tried to setup a Smart Group and link this to a Role in Civi using Groups Role Sync, but this plugin does not work with smart groups.
  
  I created a Parent ACL group of the smart group in question, but this is not being populated.
  
  I've also tried creating a CiviRule to add a membership when custom fields are edited and then use the membership sync to role plugin, but CiviRules can't evaluate the values in multi record custom data groups (for understandable reasons).
  
  So.... I was wondering if anyone had any other ideas of how we can automatically add a capability or role in WordPress based on the data in CiviCRM? Maybe someone could share some custom code for a plugin to do this, [similair to this answer](https://civicrm.stackexchange.com/questions/17710/syncing-drupal-roles-from-civicrm-smart-groups/19523#19523) but for WordPress?
  
  **Tags:** wordpress, smartgroups, roles
  
  > **Comments:**
  > **username_0**: This is the Group Role Sync plugin for WordPress: https://develop.tadpole.cc/plugins/civicrm-groups-sync  
  > **username_1**: One way to sidestep Smart Groups is to instead add folk to a Group via CiviRules if the 'trigger' of why someone should be in the group can be easily defined  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2020-03-30. Score: 1
  
  I'm not sure what "Groups Role Sync" is (I suspect it's a Drupal module) but you can use [CiviCRM WordPress Member Sync](https://wordpress.org/plugins/civicrm-wp-member-sync/) to sync Contacts with Memberships to WordPress Users with Roles or Capabilities. FWIW, the plugin doesn't support Smart Groups either.
  
  > **Comments:**
  > **username_0**: Thanks @christian but we need to specifcally support smart groups. This is the plugin for WordPress to do Group Role sync: https://develop.tadpole.cc/plugins/civicrm-groups-sync  
  > **username_2**: @username_0 That plugin doesn't support smart groups either.  
  > **username_2**: Perhaps you can explain why you need the sync to be on the basis of a Smart Group?  
  > **username_2**: To clarify - Smart Groups cannot be of type "Access Control", so they shouldn't really be used for that purpose.  
  > **username_0**: We don't neccesarily need to use Smart Groups, but there doesn't seem to be another way to add a capability automatically based on data held in Civi?  
  > **username_2**: @username_0 Both of the plugins we're discussing grant capabilities to WordPress Users depending on what happens in CiviCRM - CWMS bases this on a Contact's Membership status whilst CGS does this on the basis of a Contact's Group Membership. Perhaps you can edit your question to explain what circumstances should cause a WordPress User (synced to a Contact) to be granted a capability?  
  > **username_0**: Hi @Christian I've explained the requirement above. Hopefully this clarifies what we're trying to do.  
  > **username_2**: @username_0 Ah, I see - thanks. Will email you my thoughts and update the answer here when we reach a sensible conclusion  
  
  ---
  
  