diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php
index 4065bed5db39..be483125d794 100644
--- a/CRM/Event/Form/Registration/Register.php
+++ b/CRM/Event/Form/Registration/Register.php
@@ -1186,7 +1186,8 @@ public static function checkRegistration($fields, $form, $isAdditional = FALSE)
}
$participant->is_test = 0;
$participant->find();
- $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
+ // Event#30 - Anyone whose status type has `is_counted` OR is on the waitlist should be considered as registered.
+ $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1') + CRM_Event_PseudoConstant::participantStatus(NULL, "name = 'On waitlist'");
while ($participant->fetch()) {
if (array_key_exists($participant->status_id, $statusTypes)) {
if (!$isAdditional && !$form->_values['event']['allow_same_participant_emails']) {
@@ -1196,8 +1197,9 @@ public static function checkRegistration($fields, $form, $isAdditional = FALSE)
if ($form->_pcpId) {
$registerUrl .= '&pcpId=' . $form->_pcpId;
}
-
- $status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've received this message in error, please contact the site administrator.") . ' ' . ts('You can also register another participant.', [1 => $registerUrl]);
+ $registrationType = (CRM_Event_PseudoConstant::getKey('CRM_Event_BAO_Participant', 'participant_status_id', 'On waitlist') == $participant->status_id) ? 'waitlisted' : 'registered';
+ $status = ts("It looks like you are already %1 for this event. If you want to change your registration, or you feel that you've received this message in error, please contact the site administrator.", [1 => $registrationType]);
+ $status .= ' ' . ts('You can also register another participant.', [1 => $registerUrl]);
CRM_Core_Session::singleton()->setStatus($status, ts('Oops.'), 'alert');
$url = CRM_Utils_System::url('civicrm/event/info',
"reset=1&id={$form->_values['event']['id']}&noFullMsg=true"
diff --git a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php
index a82268ea909a..f48137d1c9d1 100644
--- a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php
+++ b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php
@@ -57,4 +57,44 @@ public function testMinValueForPriceSet() {
$this->checkArrayEquals($expectedResult, $errors);
}
+ /**
+ * event#30
+ */
+ public function testDoubleWaitlistRegistration() {
+ // By default, waitlist participant statuses are disabled (which IMO is poor UX).
+ $sql = "UPDATE civicrm_participant_status_type SET is_active = 1";
+ CRM_Core_DAO::executeQuery($sql);
+
+ // Create an event, fill its participant slots.
+ $event = $this->eventCreate([
+ 'has_waitlist' => 1,
+ 'max_participants' => 1,
+ 'start_date' => 20351021,
+ 'end_date' => 20351023,
+ 'registration_end_date' => 20351015,
+ ]);
+ $this->participantCreate(['event_id' => $event['id']]);
+
+ // Add someone to the waitlist.
+ $waitlistContact = $this->individualCreate();
+
+ $firstWaitlist = $this->participantCreate(['event_id' => $event['id'], 'contact_id' => $waitlistContact, 'status_id' => 'On waitlist']);
+
+ // We should now have two participants.
+ $this->callAPISuccessGetCount('Participant', ['event_id' => $event['id']], 2);
+
+ $form = new CRM_Event_Form_Registration_Register();
+ $form->controller = new CRM_Core_Controller();
+ $form->set('id', $event['id']);
+ $form->set('cid', $waitlistContact);
+ // We SHOULD get an error when double registering a waitlisted user.
+ try {
+ $form->preProcess();
+ }
+ catch (CRM_Core_Exception_PrematureExitException $e) {
+ return;
+ }
+ $this->fail('Waitlisted users shouldn\'t be allowed to re-register.');
+ }
+
}