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

CiviCRM Groups instead of Memberships #9

Closed smargovsky closed 8 years ago

smargovsky commented 8 years ago

Hello,

I'm investigating syncing between Civi Contact Groups and Wordpress Roles / Capabilities. Your plugin that syncs Civi Groups to BuddyPress Groups seems to do half the work and this plugin the other half.

Any advice from your experience with both plugins to help a developer on their way?

Any reason you haven't done something like this already?

Thanks for your time in this regard, and the work on both of these plugins!

christianwach commented 8 years ago

Any reason you haven't done something like this already?

These two plugins are basically ports of the Drupal modules that do more-or-less the same job. It's tricky (and somewhat arbitrary) deciding what to sync with what, so I thought that the barriers to migration from Drupal to WordPress would be lower if Drupal/CiviCRM developers could see how quick it was to port their favourite functionality to WordPress. It hasn't led to the deluge of WordPress/CiviCRM plugins that I thought it might, but there we are.

Any advice from your experience with both plugins to help a developer on their way?

I'd use BP Groups CiviCRM Sync as a starting point. You can then use the following hooks to achieve your aim (though I'd recommend capabilities rather than roles):

You could be more granular about the role or capabilities assigned to a user if you map their group role to one or more WordPress capabilities. You would then use bp_groups_civicrm_sync_member_demoted and bp_groups_civicrm_sync_member_promoted and the usual suite of BuddyPress group-related hooks to tweak the caps.

Having said that, why assign a role or caps if you already have the information about a user's BuddyPress group membership? You can simply poll groups_is_user_member(), groups_is_user_mod() and groups_is_user_admin() to retrieve essentially the same information. Are there plugins you use (or want to use) that work with purely with caps? If so, it would make sense to look at the way this plugin interfaces with the Groups plugin and amend that to your needs.

smargovsky commented 8 years ago

Thank you for the response. To clarify - I am not interested in using Buddy Press at all on this project. Just a vanilla CiviCRM Groups to Wordpress Capabilities / Roles sync.

christianwach commented 8 years ago

I'm curious what you have against using BuddyPress which I think is highly useful in many respects. However, if you prefer to avoid it, you could roll your specific implementation from the relevant Civi hooks and the role/caps code in this plugin.