Answers.Body: <p>João: By design WordPress user capabilities are restricted to a single site because many Multisite instances treat sub-sites as entirely separate entities. So in order to achieve what you want, you'll have to:</p>
  
  <ol>
  <li>explicitly propagate users and their capabilities to the sub-site(s)</li>
  <li>propagate the Groups plugin sync to the sub-site(s)</li>
  </ol>
  
  <p>Task 1 is fairly straightforward: you'd use the <code>civi_wp_member_sync_add_cap</code> hook to detect when a capability has been added to a user. First add the user to your sub-site(s) with <code>add_user_to_blog()</code>, then <code>switch_to_blog()</code> and add the capability to the user before switching back to the current site.</p>
  
  <p>Task 2 is a little more tricky. The Groups plugin <a href="https://wordpress.org/plugins/groups/" rel="nofollow">states that</a> "All features are supported independently for each blog in multisite installations". As a result (as you've discovered) the CiviCRM WordPress Member Sync plugin only syncs capabilities to the Groups plugin on the main site. To propagate that sync to the sub-site, you'll need to use the family of <code>civi_wp_member_sync_rule_*_capabilities</code> hooks and sync the capabilities to the Groups plugin instance on the sub-site(s) yourself. If it makes life easier, I can add some <code>do_action</code> calls in the relevant places so that you can guarantee that your code will run when expected.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-07T14:12:21.263Z
Answers.Text: For propagating users I have already a plugin to do that - all users are present on both sides.
  I don't know how to include those actions from task 2 as I'm not familiar with programming. Is that some sort of code to include on the plugin already doing the users sync?
Answers.UserDisplayName: João Cunha
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-08T14:58:17.673Z
Answers.Text: Yes, some programming will be necessary. A developer will understand what I've written in my answer.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-06T21:45:20.947Z
Answers.LastActivityDate: 2016-01-06T21:45:20.947Z
Answers.UserDisplayName: Christian Wach
Body: <p>I'm setting up an association website integrated with CiviCRM (used for membership management among other features).</p>
  
  <p>The wordpress site is a multisite install: a main site, where CiviCRM is active and showing, and a ecommerce subsite where CiviCRM is active but not showing (using the CiviCRM admin tool).</p>
  
  <p>On the main site I'm using capabilities associated with membership types. For example, membership type 1 adds automatically to wordpress users the civimember_1 capability. Then I use this capabilities to restrict access to some special pages where only active members should be authorized to see.</p>
  
  <p>While on the main site it works great, on the subsite dedicated to the store, those capabilities are not showing. There are a couple of civicrm-related capabilities showing on the groups plugin, but the membership-related capabilities don't and therefore I can't restrict some articles to active members.</p>
  
  <p>How can I do in order to have the civicrm capabilities also on site 2?</p>
  
  <p>From what I read I'm not interested in a multisite CiviCRM as different domains don't mean different groups or organisations, I just want CiviCRM to communicate specific capabilities to all my wordpress sites (they are using the same DB, of course).</p>
  
  <p>Can anyone help?</p>
  
  <p>Cheers
  João</p>
  
Tags: <wordpress><civimember><user>
Title: Wordpress multisite capabilities
ThreadText: # Wordpress multisite capabilities
  
  (Asked by: username_0 on 2016-01-05)
  
  I'm setting up an association website integrated with CiviCRM (used for membership management among other features).
  
  The wordpress site is a multisite install: a main site, where CiviCRM is active and showing, and a ecommerce subsite where CiviCRM is active but not showing (using the CiviCRM admin tool).
  
  On the main site I'm using capabilities associated with membership types. For example, membership type 1 adds automatically to wordpress users the civimember\_1 capability. Then I use this capabilities to restrict access to some special pages where only active members should be authorized to see.
  
  While on the main site it works great, on the subsite dedicated to the store, those capabilities are not showing. There are a couple of civicrm-related capabilities showing on the groups plugin, but the membership-related capabilities don't and therefore I can't restrict some articles to active members.
  
  How can I do in order to have the civicrm capabilities also on site 2?
  
  From what I read I'm not interested in a multisite CiviCRM as different domains don't mean different groups or organisations, I just want CiviCRM to communicate specific capabilities to all my wordpress sites (they are using the same DB, of course).
  
  Can anyone help?
  
  Cheers
  João
  
  **Tags:** wordpress, civimember, user
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-06. Score: 1
  
  João: By design WordPress user capabilities are restricted to a single site because many Multisite instances treat sub-sites as entirely separate entities. So in order to achieve what you want, you'll have to:
  
  1. explicitly propagate users and their capabilities to the sub-site(s)
  2. propagate the Groups plugin sync to the sub-site(s)
  
  Task 1 is fairly straightforward: you'd use the `civi_wp_member_sync_add_cap` hook to detect when a capability has been added to a user. First add the user to your sub-site(s) with `add_user_to_blog()`, then `switch_to_blog()` and add the capability to the user before switching back to the current site.
  
  Task 2 is a little more tricky. The Groups plugin [states that](https://wordpress.org/plugins/groups/) "All features are supported independently for each blog in multisite installations". As a result (as you've discovered) the CiviCRM WordPress Member Sync plugin only syncs capabilities to the Groups plugin on the main site. To propagate that sync to the sub-site, you'll need to use the family of `civi_wp_member_sync_rule_*_capabilities` hooks and sync the capabilities to the Groups plugin instance on the sub-site(s) yourself. If it makes life easier, I can add some `do_action` calls in the relevant places so that you can guarantee that your code will run when expected.
  
  > **Comments:**
  > **username_0**: For propagating users I have already a plugin to do that - all users are present on both sides. I don't know how to include those actions from task 2 as I'm not familiar with programming. Is that some sort of code to include on the plugin already doing the users sync?  
  > **username_1**: Yes, some programming will be necessary. A developer will understand what I've written in my answer.  
  
  ---
  
  