1

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

1 Answer 1

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 "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.

2
  • 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? Commented Jan 7, 2016 at 14:12
  • Yes, some programming will be necessary. A developer will understand what I've written in my answer. Commented Jan 8, 2016 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.