CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Civimember roles sync - not running automatically when membership updated
Pages: [1]

Author Topic: Civimember roles sync - not running automatically when membership updated  (Read 2306 times)

Dave Melkman

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: CiviCRM 4.0.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.14
  • PHP version: 5.3.6
Civimember roles sync - not running automatically when membership updated
November 03, 2011, 10:01:38 am
Hi,
We're having trouble with this functionality. 
Using the module in Drupal 7 we're trying to get roles to sync in Drupal when a new membership is created in Civi.  It works fine when manually synchronising but if we use the setting 'Synchronize when membership is updated. '  it never updates automatically.
Has anyone else had this problem or has anyone else in fact got it working ok in Drupal 7 - Civi 4.0.5

Thanks
Dave

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Civimember roles sync - not running automatically when membership updated
March 12, 2012, 04:03:30 am
I have the same problem, but on a Drupal 6 site running CiviCRM 3.4.7. I'm looking around to see if there are any issues around this functionality that i need to be aware of. No luck as yet. Any pointers would be most welcome.

Regards
Graham
Graham Mitchell
http://mc3.coop

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Civimember roles sync - not running automatically when membership updated
March 12, 2012, 02:31:01 pm
hi - this might not be quite the answer to your question but it has stumped people before so may be useful to repeat for others benefits if not yours. As i understand things ...
Depending on your settings, a change of Membership (or Group) status will not immediately be reflected in the Users roles since those roles get allocated the next time the user logs in.
Ie, if an admin gives a user a Membership via the backend, and you then go look at the user, then you will not see any related Role as having been granted to the user, and may conclude something isn't working.
But when the user logs in, the system goes 'hmm wonder what roles to give this person, i had better go check if they should get any Roles based on their Civi Member (or Groups) status and if so, either give or take away the necessary Roles.'
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Civimember roles sync - not running automatically when membership updated
March 16, 2012, 10:04:11 am
Pete hi, and many thanks for pitching in on this one.

I have to say you have me confused now. My understanding of the Civimember roles sync module is that there are three options as to how the membership change will sync with the Drupal role:
1. via cron
2. when the user logs in/out
3. when the membership status changes.

It the third option that i want to use, and I expect it to work such that when a user logs in to the site and signs up for a membership, their Drupal role is changed to reflect that signup. This is certainly the implication by my reading of the Dharmatech post at http://dharmatech.org/ideas/2011/improved-civimember-roles-synchronization

From what you have written I understand that the change only works when a user logs out and back in, regardless? This seems to run counter to the Dharmatech post, which, judging by its date - Jan 2011, those changes will be in the bundled Drupal module in CiviCRM version 3.4.7 (released Oct 2011) - the version used in this case.

Any one else able to cast light on this?
« Last Edit: March 16, 2012, 03:26:25 pm by Upperholme »
Graham Mitchell
http://mc3.coop

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Civimember roles sync - not running automatically when membership updated
March 16, 2012, 01:18:00 pm
hi - my posting wasn't meant to cover the situation of someone who is logged in, and who then changes their membership status to something that would give them a new role and hence new access to content.
my naive thinking is that drupal still needs to be asking the question 'what roles should this user have' and i have no idea if changing a logged in persons membership status can do this while they are still logged in.
keen to hear the answer if someone has it. otherwise sounds like if this used to happen and now doesn't that the module needs some TLC
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Dave Melkman

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: CiviCRM 4.0.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.14
  • PHP version: 5.3.6
Re: Civimember roles sync - not running automatically when membership updated
April 03, 2012, 06:34:15 am
We've had a little breakthrough with this which we discovered when looking through the example module code for hook_civicrm_post (http://wiki.civicrm.org/confluence/display/CRMDOC41/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmpost)

It just involves a minor change to the names of the variables used in the last function of the civicrm_member_roles.module file.

This is the original code:

Code: [Select]
function civicrm_member_roles_civicrm_post($op, $objname, $objid, &$objref) {
    if ($objname == "Membership") {
        if (variable_get('civicrm_member_roles_sync_method', 0) == 3) {
            _civicrm_member_roles_sync(NULL, $objref->contact_id);
        }
    }
}

which we replaced with this:

Code: [Select]
function civicrm_member_roles_civicrm_post($op, $objectName, $objectId, &$objectRef) {
   if ($objectName == "Membership") {
        if (variable_get('civicrm_member_roles_sync_method', 0) == 3) {
            _civicrm_member_roles_sync(NULL, $objectRef->contact_id);
        }
    }
}

and all now seems to work ok.

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Civimember roles sync - not running automatically when membership updated
April 25, 2012, 08:44:45 am
Any idea if this has been rolled in to the released module in version 4.1.2?
Graham Mitchell
http://mc3.coop

Dave Melkman

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: CiviCRM 4.0.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.14
  • PHP version: 5.3.6
Re: Civimember roles sync - not running automatically when membership updated
April 25, 2012, 09:35:31 am
No it hasn't, we just upgraded to Civi 4.1.2 and I had to copy this snippet of code across manually

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Civimember roles sync - not running automatically when membership updated
April 25, 2012, 09:59:32 am
I'll raise an issue for it, and hope we can get it into the next release.

http://issues.civicrm.org/jira/browse/CRM-10107
« Last Edit: April 25, 2012, 10:10:40 am by Upperholme »
Graham Mitchell
http://mc3.coop

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Civimember roles sync - not running automatically when membership updated
April 25, 2012, 10:03:06 am

i cant see a diff between the two code snippets? can u elaborate a bit more on what the change is and why changing the variable name makes a difference?

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Dave Melkman

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
  • CiviCRM version: CiviCRM 4.0.5
  • CMS version: Drupal 7
  • MySQL version: 5.5.14
  • PHP version: 5.3.6
Re: Civimember roles sync - not running automatically when membership updated
April 25, 2012, 10:07:53 am
The only difference changing all instances of the names of the variables used in the function (ie. $objectName, $objectId, &$objectRef). 
I'm kind of surprised this made a difference but changing these to match the exact syntax given in hook specification code made all the difference.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Civimember roles sync - not running automatically when membership updated

This forum was archived on 2017-11-26.