Which contact id should be used
Created by: wdecraene
In cividiscount_civicrm_buildAmount there is some logic to determine the contact id:
if (!empty($form->_pId)) {
$contact_id = $form->_pId;
}
// Look for contact_id in the form.
else if ($form->getVar('_contactID')) {
$contact_id = $form->getVar('_contactID');
}
// note that contact id variable is not consistent on some forms hence we need this double check :(
// we need to clean up CiviCRM code sometime in future
else if ($form->getVar('_contactId')) {
$contact_id = $form->getVar('_contactId');
}
// Otherwise look for contact_id in submit values.
else if (!empty($form->_submitValues['contact_select_id'][1])) {
$contact_id = $form->_submitValues['contact_select_id'][1];
}
// Otherwise use the contact id.
else {
$contact_id = CRM_Core_Session::singleton()->get('userID');
}
I think we should add an extra 'elseif':
elseif ($form->getContactID() != 0) {
$contact_id = $form->getContactID();
}
Or even replace the last logic statement:
else {
$contact_id = $form->getContactID();
}
When a user subscribes another contact to an event, the id of that other contact will be taken.