Answers.Body: <p>It can be easily done using hooks. Max participant is stored in civicrm_event table, so you need to fetch the value and then compare it with the count of participants registered in this event. All this check should be done after a participant is created. So, you could use post hook for the same. Sample(not tested) code is shown below -</p>
  
  <pre><code>function example_civicrm_post($op, $objectName, $objectId, &amp;$objectRef) {
    if ($op == 'create' &amp;&amp; $objectName == 'Participant') {
      //check the count of participant in the event
      $participantCount = civicrm_api3('Participant', 'getcount', [
        'event_id' =&gt; $objectRef-&gt;event_id,
      ]); 
  
      //Compare it with the max participant value 
      $max = civicrm_api3('Event', 'getvalue', [
        'return' =&gt; "max_participants",
        'id' =&gt; 1,
      ]);
  
      //If max equals the count, send an email
      if ($max == $participantCount) {
        //send email to xyz@example.com
      }
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-10T10:13:48.913Z
Answers.Text: Super, thanks for the suggestion! I'll try it out and let you know.
Answers.UserDisplayName: minbori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-09T13:33:39.960Z
Answers.LastActivityDate: 2018-10-09T13:33:39.960Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>I'd like to be able to notify organizers when a certain number of participants have registered.  I don't want to shut down registration or offer a waiting list to participants, I just need the staff notified via email.</p>
  
  <p>Is there a way to do this out-of-the-box?  Could I do this with the CiviRules component?  If not, other suggestions on hooks/customizations welcome.</p>
  
  <p>Thanks!</p>
  
  <p>System deets:  Joomla 3.8.12, CiviCRM 5.3.1</p>
  
Tags: <civievent><email><civirules><participants>
Title: CiviEvent: possible to trigger an email to event organizer when participant count reaches a certain number?
ThreadText: # CiviEvent: possible to trigger an email to event organizer when participant count reaches a certain number?
  
  (Asked by: username_0 on 2018-10-09)
  
  I'd like to be able to notify organizers when a certain number of participants have registered. I don't want to shut down registration or offer a waiting list to participants, I just need the staff notified via email.
  
  Is there a way to do this out-of-the-box? Could I do this with the CiviRules component? If not, other suggestions on hooks/customizations welcome.
  
  Thanks!
  
  System deets: Joomla 3.8.12, CiviCRM 5.3.1
  
  **Tags:** civievent, email, civirules, participants
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-09. Score: 1 | Accepted answer
  
  It can be easily done using hooks. Max participant is stored in civicrm\_event table, so you need to fetch the value and then compare it with the count of participants registered in this event. All this check should be done after a participant is created. So, you could use post hook for the same. Sample(not tested) code is shown below -
  
  ```
  function example_civicrm_post($op, $objectName, $objectId, &$objectRef) {
    if ($op == 'create' && $objectName == 'Participant') {
      //check the count of participant in the event
      $participantCount = civicrm_api3('Participant', 'getcount', [
        'event_id' => $objectRef->event_id,
      ]); 
  
      //Compare it with the max participant value 
      $max = civicrm_api3('Event', 'getvalue', [
        'return' => "max_participants",
        'id' => 1,
      ]);
  
      //If max equals the count, send an email
      if ($max == $participantCount) {
        //send email to xyz@example.com
      }
    }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Super, thanks for the suggestion! I'll try it out and let you know.  
  
  ---
  
  