Giter Club home page Giter Club logo

Comments (12)

oobi avatar oobi commented on May 27, 2024

I forgot to mention I'm on WP 4.3.1 and CiviCRM 4.6 and I have the 'Members' plugin installed

from civicrm-wp-profile-sync.

oobi avatar oobi commented on May 27, 2024

We found the reason... if a user in WP does NOT have a role assigned (not sure how/why this happened - perhaps a glitch somewhere during import maybe?) then the sync plugin ignores it. The expiry role is set to "anonymous user". If I add that to the user who should have active membership and then sync then it all works swimmingly.

Is it possible to have the sync pick up users who aren't currently "anonymous user" and assign the role 'member' where the rule meets the active membership criteria? All I really want it to do is tick or untick the "member" role.

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

@oobi Thanks for the report. I'm not sure it's the place of this plugin to audit and fix people's WordPress installs, but I'll think about what warnings it could display.

All I really want it to do is tick or untick the "member" role.

Does the plugin not do this for your users (well, at least for users those who do have a role)?

from civicrm-wp-profile-sync.

oobi avatar oobi commented on May 27, 2024

It does work when users do have the specified roles, yes. Adding or removing a membership then toggles between the active and inactive role (member/anonymous).

The issue may just be a mismatch in my expectation of what it's intended to do. I had assumed that the sync would apply the appropriate WP group to any user who didn't already have it set so as to keep Civi as the "source of truth" for the correct user state.

It seems to work like this:

is Civi member and is WP anonymous?
    unset WP anonymous, set WP member

is NOT Civi member and is WP member? 
    unset WP member, set WP anonymous

I guess what I had expected was more along the lines of

is Civi member and not WP member?
    set WP member, unset WP anonymous

is NOT Civi member and WP member?
    unset WP member, set WP anonymous

I haven't yet tried to see what it does if the user has been assigned some other role such as "author" or "editor" instead of "anonymous". WP allows us to set multiple roles, so some members have extra rights on the site.

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

I'm not sure I follow your membership conditions. How is "is Civi member and is WP anonymous?" different from "is Civi member and not WP member?" especially since they both have the same outcome of "unset WP anonymous, set WP member" (or vice versa).

This plugin essentially reacts to changes in membership status on the Civi side. So when a membership is applied to a Contact, the appropriate rule is triggered and the WordPress user receives the defined role or capability. It won't "batch affect" multiple users as such except when using "Manual Sync" which is only really intended to be run on first install.

This does in effect 'keep Civi as the "source of truth" for the correct user state' but only for those WordPress users who have a Civi membership, or for those whose membership status changes. It would be overreach for this plugin to affect all WordPress users regardless, since there are any number of ways that a WordPress install can be set up. There are, however, filters and actions in place that would allow you to code things that way if you wanted to.

Disclaimer: I only use role sync on a test site. WordPress works more fluently with capabilities, so that's what I use for production sites.


Edit: I wanted to expand on your comment about roles such as "author" or "editor", which is one of the prime reasons I use capabilities. Imagine you have a WordPress user with "author" role who (for whatever reason) signs up for a Civi membership. Now imagine that membership grants "subscriber" role because it's largely used for public signups on your site. Suddenly your author is demoted to "subscriber" on the site and is locked out of areas that they could previously access. If you use capabilities, on the other hand, then no such problem occurs: WordPress role is completely independent of Civi membership, and therefore having one or more Civi memberships simply grants a user those extra capabilities on the site. You can switch the WordPress user from "contributor" to "editor" and the capabilities granted by membership will be unaffected.

Sure you can use multiple roles as Drupal does, but I find the implementation of this in WordPress to be clumsy at best and IIRC the core WP devs recommend the capabilities approach instead. Having said that, I know that bbPress adds an additional role to users when installed - a situation that this plugin takes those into account when applying its association rules. Have a look at the way this plugin integrates with the Groups plugin if you're interested in a more nuanced approach.

from civicrm-wp-profile-sync.

oobi avatar oobi commented on May 27, 2024

The distinction between the tests I mentioned is whether presence or absence of the anonymous role has a bearing on whether the Civi member should be assigned the active member role. I haven't dug through the code to verify what's being checked, but from observation it seem to ask "is this user in the inactive member role" before assigning the active member role. I would have thought a more appropriate test would be "is this user NOT in the active role".

This applies to a full manual sync or when changing (adding/removing/editing) membership. It works really well provided the conditions above are met.

I wasn't suggesting that all WP users should be affected - just the ones linked to changes in Civi (the way it works now). It's just the test for "should I activate this guy or not" I was questioning.

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

it seem to ask "is this user in the inactive member role" before assigning the active member role. I would have thought a more appropriate test would be "is this user NOT in the active role".

Ah, I see now, thanks. I see that it's a conundrum specific to role sync that doesn't apply to capability sync. The edit to my previous comment explains why I think capability sync is more a more WordPress-friendly approach... but I'll have a think about the issue you've raised.

from civicrm-wp-profile-sync.

oobi avatar oobi commented on May 27, 2024

thanks for your time :)

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

It strikes me that we're discussing this in the issue queue for the wrong plugin - I think this discussion refers to CiviCRM WP Member Sync rather than this one :-)

from civicrm-wp-profile-sync.

oobi avatar oobi commented on May 27, 2024

you're dead right - my bad!

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

@oobi I'd like to close this, but wanted to check with you that the Member Sync plugin works at it should...

from observation it seem to ask "is this user in the inactive member role" before assigning the active member role

I don't think this observation is correct. Since the initial commit, the plugin's logic has always been to check only if the primary role differs from the role indicated by the sync rule. See this line and this line for details. I can't see how even not having a role at all would alter the decision to switch the user's role to satisfy the sync rule.

from civicrm-wp-profile-sync.

christianwach avatar christianwach commented on May 27, 2024

@oobi Please can you open a new issue on the CiviCRM WP Member Sync repo if the 0.3 update doesn't perform the sync as you expect it to? I've reworked the sync routines for the latest release.

Cheers, Christian

from civicrm-wp-profile-sync.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.