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) »
  • civicrm_member_roles for new member sign-up
Pages: [1]

Author Topic: civicrm_member_roles for new member sign-up  (Read 1416 times)

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
civicrm_member_roles for new member sign-up
August 22, 2013, 02:37:56 am
Hello

We're using 4.2.6 on Drupal 7.  We have a contribution with membership sign up.  We are also using civicrm_member_roles to assign roles based on membership type when someone logs in or out.

Currently the right role is not assigned when someone signs up and so we have to ask them to log out and log in again.  It would be nice to avoid this.

civicrm_member_roles reports to the Drupal log eg: "The uid: 12345 did not have a CiviCRM Contact ID."
in civicrm_member_roles.module _civicrm_member_roles_sync()

It does this because there is no entry in the civicrm_uf_match table.
A Contact ID has been assigned when CRM_Contribute_BAO_Contribution_Utils::createCMSUser() is called in Contribution/Confirm.php
However the civicrm_member_roles hook_user_login is called before an entry can be added to civicrm_uf_match.

Has this been spotted before?  And sorted in a later version?

Can there be special handling to cover this case in _civicrm_member_roles_sync()?
I'm not sure if a session variable can be added before the Drupal user is created.
Simply create some global?

Chris

(Couldn't find an existing report of this issue.)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_member_roles for new member sign-up
August 22, 2013, 02:56:17 pm
I don't know if this one helps at all

http://issues.civicrm.org/jira/browse/CRM-11838

It doesn't look like any other changes have been made to this module since 4.3 or whenever the git switch was

https://github.com/civicrm/civicrm-drupal/tree/7.x-master/modules
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
August 24, 2013, 02:04:19 am
Thanks Eileen

I don't think CRM-11838 will help.

I'll see if I can work out something and suggest it as an improvement.
I'll have to pass some info from CRM_Contribute_Form_Contribution_Confirm processContribution() to civicrm_member_roles.module _civicrm_member_roles_sync() ie for when createCMSUser() is called.  It's a bit yucky but a static variable might do the trick.

Chris

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_member_roles for new member sign-up
August 25, 2013, 01:49:37 pm
sounds like you could create the uf match yourself?
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
August 25, 2013, 02:00:04 pm
Could do.  I guess it's normally created later in the process; I don't want two entries made...
Anyway, I'll have a look.
Ta Chris

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
August 30, 2013, 07:31:25 am
I have worked out how to add a ufmatch entry in civicrm_member_roles but that turned out to be too early.  It avoids one error in the log but doesn't give the right roles as desired.

I guess it is because the membership hasn't been fully created yet.  Where should I be looking to do the role update?
It could be at the end of CRM\Member\BAO\Membership.php postProcessMembership()
Or it might be at the end of CRM\Member\Form\Membership.php postProcess()

Now: how to force a role update?
I was trying to see how "Synchronize when membership is updated" is handled which must be when Drupal variable civicrm_member_roles_sync_method is 2.
I can see where option 0, 1 and 3 are handled, but 2.
Can anyone give me a pointer?

Ta Chris

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: civicrm_member_roles for new member sign-up
August 30, 2013, 09:34:57 am

from a quick look at the code, 2 is manual sync

Code: [Select]
     2 => t('Disable automatic synchronization. You will have to use the "Manually Synchronize" form to synchronize memberships and roles yourself.'),

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

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
August 30, 2013, 10:21:21 am
Ah yes thanks.  I assumed the values corresponded to the order on screen.

civicrm_member_roles_civicrm_post() is being called.  I haven't confirmed it but I guess this is at the right time ie after the user has been created, the contribution and membership recorded.

Does the "Synchronize when membership is updated" sync get called when the cron/scheduled job runs to change the membership from Current to Grace, etc?  If so, then simply switching to this setting may solve all the problems.

If not, then we will want  to have both "Synchronize whenever a user logs in or logs out" and "Synchronize when membership is updated".

Ta Chris

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: civicrm_member_roles for new member sign-up
August 30, 2013, 12:02:52 pm

the cron / scheduled jobs bootstraps drupal, so the hooks should be called if present

might want to run a quick test and check.

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

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
August 30, 2013, 12:48:41 pm
I re-ran Membership status processor but civicrm_member_roles_civicrm_post() wasn't called.  However it has already been run today.  I'll see if any calls show up over the weekend - I'm sure there ought some memberships expiring.

Ta Chris

http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_post

chriscant

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 4
    • PHDCC
  • CiviCRM version: 4.2.19
Re: civicrm_member_roles for new member sign-up
September 05, 2013, 04:46:03 am
I tried changing to "Synchronize when membership is updated".  Once I'd changed, I tried a real signup by paying for a membership with a contribution.  I'd pressed Continue to go to PayPal.  However it hung up saying "Processing...".  There's no error in the Drupal log.

I reverted back to "Synchronize whenever a user logs in or logs out. This action is performed only on the user logging in or out." and I get through to PayPal.

Any ideas why the transfer to PayPal should hang up in this case?

Thanks in advance.
Chris

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • civicrm_member_roles for new member sign-up

This forum was archived on 2017-11-26.