Support

Home Forums Event Espresso Premium Minimum Attendees Reply To: Minimum Attendees

Reply To: Minimum Attendees

Author Replies
Josh # Posted on April 24, 2018 at 3:10 pm

The only way to automate notifications that certain classes haven’t met the minimum would be to build a custom plugin with that specific functionality.

Rather than building a private page that lists out upcoming classes and the number of registrations, you could instead use the regular event list and just display the registration count for the logged in site admin.

So for example you could add this code to a site specific plugin:

add_action( 
    'AHEE_event_details_after_the_content', 
    'ee_display_registration_count', 
    10, 
    2 
);
function ee_display_registration_count( $post ) {
  if(!current_user_can('ee_edit_events')){
    return; // get out!
  }
  $event = $post->EE_Event;
  if ( $event instanceof EE_Event ) {
    if ( ! $event->is_sold_out() && $event->is_upcoming() ) {
      //get total approved registrations count
      $spots_taken = EEM_Registration::instance()->count(array(
        array(
          'EVT_ID' => $post->ID,
          //'STS_ID' => EEM_Registration::status_id_approved,
        ),
      ), 'REG_ID', true);
      // output some html
      $style = 'background-color:#efefef;';
      $style .= 'text-align:center;';
      $style .= 'padding:2em; margin:1em;';
      $style .= 'font-weight:bold;';
      $html = '<div style="'.$style.'" class="registrations">';
      $html .= 'Number of registrations: ';
      $html .= $spots_taken . '</div>';
      echo $html;
    }
  }
}

and that will display the registration count if they’re logged into the site and have the capability to edit Event Espresso events.

Do NOT follow this link or you will be banned from the site!