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 CiviEvent (Moderator: Yashodha Chaku) »
  • Crediting the logged in user for registering other people
Pages: [1]

Author Topic: Crediting the logged in user for registering other people  (Read 1629 times)

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Crediting the logged in user for registering other people
February 17, 2011, 02:00:28 pm
I may be missing something so I thought I would post and see. :)

I want to allow people who have already registered for an event to come back later and register other people, or to register people without registering themselves in the first place.  Most importantly I want the people doing the registering to get the credit for the contribution tied to the registration regardless of whether or not they register themselves for the event.

From the looks of it (and from what I can tell in the code) the first person you register get a contribution record for the registration as opposed to the person logged in.  Am I missing something?

This is something I could deal with in a hook_civicrm_pre hook if I could pass a variable (maybe via the url in on line 1237 of CRM_Event_Form_Registration_Register). I could then intercept the registration in the hook (maybe in hook_civicrm_postProcess) and point the contribution to the desired contact.


BTW version 3.3.5
« Last Edit: February 17, 2011, 02:07:49 pm by jalama »
http://www.rootyhollow.com

Rajan Mayekar

  • I post frequently
  • ***
  • Posts: 177
  • Karma: 20
    • Rajan's Blogs
Re: Crediting the logged in user for registering other people
February 17, 2011, 09:22:19 pm
If I understood u correctly, I suspect that this is already available.
Any user can register others also ( with/ without himself ), you may try url like
Code: [Select]

civicrm/event/register?reset=1&action=preview&id=[eventId]&cid=0
Note that I am passing cid=0 , it will considered as current user (logged In) going to register event without including himself.

Rajan
 

rjb

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Crediting the logged in user for registering other people
February 18, 2011, 02:44:22 am
Rajan is certainly correct - and there's a link to the cid=0 version of the registration form at the top of every event reg page (Welcome [name]. (Not [name], or want to register a different person?)

However, I think jalama's other question is really interesting and there are three important points here...

1) Is there any way to tie the contribution record to the person doing the registering, rather than the person being registered? I think this will also apply for the receipt / invoice (for pay later). If you're registering someone else, you probably want the receipt / invoice to go to you rather than the person you're registering.

2) The person actually attending probably doesn't need to receive payment information or pay later instructions, just the event details - so perhaps we need to fire two different emails here?

3) If you are registering multiple people, then the email [EDIT - by this I mean the email with payment information; all attendees receive emails with event information] only goes to the first one - which is especially problematic if you are registering on behalf of people NOT including yourself. Should *all* attendees not receive an email, plus the person doing the registering? EDIT: Shouldn't the person doing the registering get the payment info email, while the attendees get the event information?


I hope someone can clarify this - it seems pretty important to me, too.

Thanks,

RJB
« Last Edit: February 18, 2011, 07:08:00 am by rjb »

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
February 18, 2011, 05:54:12 am
RJB has it exactly.

I understand that someone can register someone else, I just want the contribution to be credited to the person entering the registrations, which in this case is not the person being registered. My hack will likely be to add something like firstSignup=1 to the url using setStatus in hook_civicrm_validate changing

Code: [Select]
civicrm/event/register?reset=1&action=preview&id=[eventId]&cid=0
to

Code: [Select]
so civicrm/event/register?reset=1&action=preview&id=[eventId]&cid=0&firstSignup=1
and grab that in hook_civicrm_postProcess using

Code: [Select]
CRM_Utils_Request::retrieve( 'firstSignup' , 'Positive', $this, false  );
Form there I'm not 100% sure what I will do, but it should give me something to work with.  This of course is conjecture at this point.
http://www.rootyhollow.com

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
February 22, 2011, 12:58:01 pm
okay these two hooks in a module files does the trick

btw this is Drupal 6 and civicrm 3.3.5

Code: [Select]
function MODULENAME_civicrm_pre (  $op, $objectName, $objectId, &$objectRef ) {
  if ($objectName == 'Contribution') {
    $controller = new CRM_Event_Controller_Registration();
    $newContactId = $controller->get("_firstId");
    if ( $newContactId ){
      $objectRef['contact_id'] = $newContactId;
    }
  }
}


function MODULENAME_civicrm_postProcess ($formName, &$form) {
  //Intercept sign-up based on the fact that the url is id > 0and cid == 0
  if ($formName == 'CRM_Event_Form_Registration_Register') {
    $id = CRM_Utils_Request::retrieve( 'id' , 'Positive', $form, false  );
    $cid = CRM_Utils_Request::retrieve( 'cid' , 'Positive', $form, false  );
    if ($id > 0 and $cid == 0) {
      Global $user;
      $contactId = CRM_Core_BAO_UFMatch::getContactId($user->uid);
      $form->controller->set("_firstId", $contactId);
    }
  }
}
http://www.rootyhollow.com

rjb

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Crediting the logged in user for registering other people
February 23, 2011, 01:09:15 am
Hi, Jalama

Great stuff! Could you explain what the journey would be if this were implemented?

My assumptions (please let me know if this is incorrect!):

1) User A clicks to confirm that they're registering someone else and the url changes to cid=0

2) User A registers someone else (User B).

3) User A is associated with the contribution and thus receives the primary email (including transaction details) while User B receives the secondary email (including only event details).

Question:

If User A clicks to confirm they're registering someone else (step 1 above), but then registers multiple people (Users B & C), is it still the case that User A is associated with the contribution and thus receives the primary email, while both Users B & C receive event detail emails?

Many thanks again,

RJB

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
February 23, 2011, 05:39:04 am
RJB,

I haven't yet confirmed that User B gets the confirmation e-mail but yes User A would get credit for the complete contribution if they sign up multiple people.  At this point Users B, C, D, etc... should all get confirmation e-mails also
http://www.rootyhollow.com

rjb

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Crediting the logged in user for registering other people
February 25, 2011, 07:10:48 am
Thanks, Jamala. We're in the middle of implementation dev right now, but this patch is definitely on the to do list! I'll let you know how it goes for us...

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
February 25, 2011, 01:40:39 pm
Hey No problem,
I even have one tweak for you :)  I left something out that prevent the hook_civicrm_pre form firing when you are doing other things  (like editing and deleting) the participant records

Code: [Select]
function MODULENAME_civicrm_pre (  $op, $objectName, $objectId, &$objectRef ) {
  if ($objectName == 'Contribution' && class_exists('CRM_Event_Controller_Registration')) {
    $controller = new CRM_Event_Controller_Registration();
    $newContactId = $controller->get("_firstId");
    //Credit logged in user with contribution while singing up other people
    if ( $newContactId ){
      $objectRef['contact_id'] = $newContactId;
    }
  }
}


function MODULENAME_civicrm_postProcess ($formName, &$form) {
  //Intercept sign-up based on the fact that the url is id > 0and cid == 0
  if ($formName == 'CRM_Event_Form_Registration_Register') {
    $id = CRM_Utils_Request::retrieve( 'id' , 'Positive', $form, false  );
    $cid = CRM_Utils_Request::retrieve( 'cid' , 'Positive', $form, false  );
    if ($id > 0 and $cid == 0) {
      Global $user;
      $contactId = CRM_Core_BAO_UFMatch::getContactId($user->uid);
      $form->controller->set("_firstId", $contactId);
    }
  }
}
http://www.rootyhollow.com

rjb

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Crediting the logged in user for registering other people
February 28, 2011, 08:57:10 am
Thanks! Do you think that covers all use-cases now?

Best,

RJB

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
February 28, 2011, 09:03:15 am
well to be fair we're also still testing it :)  But yes I think it's covering everything
http://www.rootyhollow.com

rjb

  • I post occasionally
  • **
  • Posts: 63
  • Karma: 2
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.1.44
  • PHP version: 5.3.1
Re: Crediting the logged in user for registering other people
February 28, 2011, 09:08:39 am
Fingers crossed ;-)

jalama

  • I post frequently
  • ***
  • Posts: 176
  • Karma: 22
    • Rooty Hollow LLC
  • CiviCRM version: 3.3.5
  • CMS version: Drupal 6 and 7
  • MySQL version: 5.1
  • PHP version: 5.2.5 and 5.3
Re: Crediting the logged in user for registering other people
March 04, 2011, 07:16:54 am
okay so we were having issues with that code and the Thank You page not coming up after you hit confirm.  So I went another route, a little simpler to be honest.  I don't like just using Raw SQL, but it was faster than using a couple API calls, so what the heck :).

Code: [Select]
function MODULENAME_civicrm_postProcess ($formName, &$form) {
          Global $user;
          $contactId = CRM_Core_BAO_UFMatch::getContactId($user->uid);
          $trxnId = $form->get('trxnId');
          $sql = "UPDATE civicrm_contribution SET contact_id = %2
                  WHERE trxn_id = %1 AND contact_id = %3";
          $params = array(
                          1 =>  array($trxnId, 'String'),
                          2 =>  array($contactId, 'Integer'),
                          3 =>  array($participant->contact_id, "Integer"),
                         );
          $dao = CRM_Core_DAO::executeQuery( $sql, $params );
}
http://www.rootyhollow.com

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Crediting the logged in user for registering other people

This forum was archived on 2017-11-26.