New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#3778 Add code hook to set civicrm_participant.created_id #24304
Conversation
(Standard links)
|
e6debea
to
70d6f67
Compare
CRM/Event/BAO/Participant.php
Outdated
* @throws CRM_Core_Exception | ||
*/ | ||
public static function self_hook_civicrm_pre(\Civi\Core\Event\PreEvent $event) { | ||
if ($event->entity === 'Participant' && $event->action === 'create' && !array_key_exists('created_id', $event->params)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good but perhaps this should be !empty
since I don't think we are encouraging NULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton Makes sense. I've updated the PR to check if the field is empty()
so that we set the field if it has not been set, or is set to NULL.
70d6f67
to
7462110
Compare
// 2. Fall back to 'registered_by_id' param. | ||
// 3. Fall back to participant contact_id (for anonymous person registering themselves) | ||
$event->params['created_id'] = CRM_Core_Session::getLoggedInContactID(); | ||
if (empty($event->params['created_id'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is redundant now - same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eileenmcnaughton No. Because we probably set it in the line above to the logged in contact ID (step 1). The other two conditions are only triggered if the created_id is still empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok right
I think this is mergeable with just one minor further fix - the |
Ideally the unit test would cover all 3 scenarios (get from logged in user, get from |
Overview
This extracts the part of #23936 that populates the
created_id
field.Before
civicrm_participant.created_id
not populated.After
civicrm_participant.created_id
populated.Technical Details
Set the "created_id" field.
The created_id should always be the person that actually did the registration.
That might be the first participant, but it might be someone registering someone without registering themselves.
Comments