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

Clarification on what this plugin does #19

Closed Upperholme closed 7 years ago

Upperholme commented 7 years ago

Hi. Many thanks for this plugin, it looks to be potentially ideal for my needs.

However I just want to clarify precisely what this plugin does. I can see that it will work very similarly to the Drupal CiviMember sync module that ships with the Drupal version of CiviCRM, i.e. synchronising membership statuses in Civi with user roles in the CMS. But from what I've read this plugin will also create a WP user in instances where a Civi contact record is created but no matching WP user already exists. Is that the case? If so, it would be great if the documentation made this explicit, as it impacts how, for example, Civi profiles may be configured.

christianwach commented 7 years ago

this plugin will also create a WP user in instances where a Civi contact record is created but no matching WP user already exists

@Upperholme Yes, that is correct, although it is only the default behaviour. There are hooks that allow you to override and/or modify the process.

Upperholme commented 7 years ago

OK, thanks. Seeking further clarification: if I set up a Civi membership sign-up form, and include in the Civi profile on that form a requirement that a WP user account be created, is it the case that the profile submission creates the WP user, and therefore that this plugin recognises that a user account has been created and so does not itself create a user account? Thanks again for your help on this.

christianwach commented 7 years ago

@Upperholme Can you explain the exact steps to achieve your scenario? I've played around with the "WordPress user account registration option" in a Profile which is attached to a Contribution Page, but cannot seem to bring up any options to create a WordPress user. I've tried checking "Give option, but not required" and "Account creation required" but still no joy. Most frustrating.

Upperholme commented 7 years ago

Hi, thanks for getting back on this. Greatly appreciated. Here's the contribution page I'm working on: https://jazzpromotionnetwork.org.uk/civi/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1 The "Wordpress user account registration option" is set to 'required' for the profile called 'Your contact details', so that when an anonymous user views the page they have to provide a username and a password. When the form is submitted a Wordpress user account is created and tied to the CiviCRM contact record. In that scenario, will the sync plugin recognise that a user account has been created and therefore not create a new user? Hope this helps.

christianwach commented 7 years ago

Thanks. At least I know what I'm looking for now. Will get back to you.

christianwach commented 7 years ago

@Upperholme Okay, so I have confirmed the behaviour of this plugin in your context. FWIW, the WordPress setting that prevents the user registration part of the form from appearing is "Anyone can register" in General Settings. That really should be highlighted in the CiviCRM Profiles help!

Anyway.

will the sync plugin recognise that a user account has been created and therefore not create a new user

Yes, that's correct. The user created by CiviCRM is not duplicated by this plugin.

Upperholme commented 7 years ago

Many thanks for spotting that one. My knowledge of Wordpress is not so great, but this makes total sense. This is just what I needed to know, so thank you very much for investigating and clarifying.

christianwach commented 7 years ago

You're welcome. FWIW, I'd always recommend developing on a copy of your live site so that you can test this sort of stuff out without affecting with the real data. Good luck with your project!

christianwach commented 7 years ago

@Upperholme Just a word of warning... it occurs to me that the CiviCRM user signup process could be a user management nightmare. I say this because as soon as the signup is complete, CiviCRM auto-logs the newly registered user in to WordPress. This looks quite neat at first glance, but I would want to test the process extensively before putting it out into the wild. On some sites, for example, I get 100 or more spammy signups every day and I would be extremely nervous about having them logged in immediately on registration, especially when offering a Pay Later option such as "I will send payment by cheque / BACS" which requires no payment. At minimum, I would map newly-registered users to the CiviCRM "Anonymous" role (or to a dummy capability) until such time as their contribution has cleared and the membership is conclusively established. I would strongly urge you to consider some kind of user moderation system.

Upperholme commented 7 years ago

Good points. I think we've got this covered, but I'll certainly double check. Thanks again!

kngs commented 7 years ago

As stated above, "this plugin will also create a WP user in instances where a Civi contact record is created but no matching WP user already exists.. it is only the default behaviour. There are hooks that allow you to override and/or modify the process."

What hooks are these and how is this done?

(I have multiple memberships but only want WP user accounts for certain ones, which I have configured using this plugin. But I am getting user accounts with "No Role" as the role, created for all other membership types that I don't want user accounts for :/

christianwach commented 7 years ago

What hooks are these and how is this done?

You'll need to search the code for apply_filters and do_action to locate all the available filters and actions. Let me know if the existing ones aren't enough for your particular circumstances.

Cheers, Christian