christianwach / civicrm-wp-member-sync

CiviCRM WordPress Member Sync plugin keeps a WordPress user in sync with a CiviCRM membership by granting either a role or capabilities to a WordPress user who has that membership.
https://wordpress.org/plugins/civicrm-wp-member-sync/
GNU General Public License v2.0
17 stars 10 forks source link

Can Member Sync with Wordpress multisites be improved, specifically CiviCRM groups to wordpress subsites.? #51

Open normancates opened 11 months ago

normancates commented 11 months ago

I'm setting up a Wordpress sub-domain multisite with CiviCRM. Site 1 is the main site, Site 2 is a subsite.

I've followed the instructions as best I can https://docs.civicrm.org/installation/en/latest/multisite/wordpress/

And I think I have it more or less working with groups in CiviCRM.

The goal I'm going for is the ability for people to subscribe to individual sites in Wordpress. Some subsites will be clubs. Some will be conventions.

In order to keep separation of people in CiviCRM, I followed the instructions to create one group for each subsite.

And used the Admin Utilities plugin to set the CiviCRM group and parent organisation.

Then I did a CiviCRM synchronise, and most of the Wordpress subscribers seemed to get the correct Group assigned. I say most because there are one or two, including my super admin account, that got no groups. BUt that isn't the point now.

In my testing, I created a Wordpress member on site 2. They have a role there. But they were not a member of site 1.

I worked out some code that let an existing user click on a button / menu item, and subscribe to a site they were not yet a member of. I used the function

add_user_to_blog(#siteID, $userID, $role );

And it successfully subscribed them to Site 1.

However, I noticed that CiviCRM has not added them to the group linked to that particular site.

I see a few options here:

THere are various reasons to keep these sub-sites from being able to see all the user data. Mainly privacy laws.

I would note that in an ideal world, running a manual synchronise would do all these checks too. ie They people are in the correct CiviCRM groups, based on the site they are subscribed to.

Thanks for any improvements you can make here :-)

normancates commented 11 months ago

Oh, I should ask. What is a domain in the context of CiviCRM? Its talked about obliquely, and its hard to know if this is something internal to CiviCRM. Or if its a reference to the subdomain of the sub-site on a multisite.

Is the domain just the subsite, therefore the domain ID is the sub-site ID?

The documentation is silent on the subject. And the setup page skates over it.

CHeers

christianwach commented 11 months ago

Thanks for any improvements you can make here

@normancates Having the code you want added to this plugin would require development time - do you have the resources to enable that to happen? Happy to help if that's the case. Alternatively - if you want a DIY approach - I'm pretty sure you can make use of the numerous actions and filters in this plugin to achieve your aims.

FWIW, multi-domain CiviCRM is a complicated business and yes, it's poorly documented... perhaps you can help to improve the docs with the hindsight of your investigations? I find the nomenclature particularly confusing - sometimes it's called CiviCRM multisite, sometimes multi-domain. Personally I don't use it because CiviEvents aren't domain-aware so I find other ways to achieve what I want.

Cheers, Christian