Commit ee600107 authored by mattwire's avatar mattwire
Browse files

Don't duplicate participants on 'CopyParticipants' Task

parent 579138f8
......@@ -121,7 +121,20 @@ class CRM_AdvancedEvents_Form_Task_CopyParticipants extends CRM_AdvancedEvents_F
if ($eventId == $params['event_source_id']) {
// Get existing participants for each event for duplicate check
$existingParticipants = civicrm_api3('Participant', 'get', [
'return' => ["contact_id"],
'event_id' => $eventId,
'options' => ['limit' => 0],
$existingParticipantContactIds = CRM_Utils_Array::collect('contact_id', $existingParticipants['values']);
foreach ($sourceParticipants['values'] as $participant) {
// Check for contact already registered for event and don't add again
if (in_array($participant['contact_id'], $existingParticipantContactIds)) {
// Add the participant to the event
$fieldsToUnset = ['id', 'participant_id', 'event_start_date', 'event_end_date', 'register_date', 'participant_register_date'];
foreach ($fieldsToUnset as $field) {
......@@ -30,7 +30,7 @@
<p>{ts}Are you sure you want to copy the selected events participants to all the others?{/ts}</p>
<p>{ts}Are you sure you want to copy the participants from the selected event to all the others (duplicates will not be created)?{/ts}</p>
<p>{include file="CRM/AdvancedEvents/Form/Task.tpl"}</p>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment