Support

Home Forums Event Espresso Premium Get Check-in Count

Get Check-in Count

Posted: August 22, 2016 at 6:39 pm


Beagle

August 22, 2016 at 6:39 pm

Hi Event Espresso team,

Is it possible to get the check-in count of an event datetime? I would like to get that data above the check-in table. I have already located the right php page, but I just need to know how to get the count.

What would be even better is if I can get check-in reports on the reports-page, but I understand it if that’s too difficult.

Thanks in advance,

Mattias


Josh

  • Support Staff

August 23, 2016 at 2:08 pm

Hi Mattias,

It will be best if you can avoid altering Event Espresso’s PHP files directly. Instead, you can use action hooks to display your count above the check-in table. Here’s some example code (which could probably use a bit more error checking, but it will get you started)

add_action( 'AHEE__admin_wrapper__template__before_admin_page_content', 'my_add_count' );

function my_add_count() {
    global $pagenow;
    if (
        $pagenow == 'admin.php'
        && isset( $_GET['route'] )
        && $_GET['route'] == 'event_registrations' 
    ) {
    $event_id = isset( $_GET['event_id'] ) ? $_GET['event_id'] : '';
    $event = EEM_Event::instance()->get_one_by_ID($event_id);
    if ( $event instanceof EE_Event ) {
      $dtt_default = $event->primary_datetime()->get('DTT_ID');
      $dtt_id = isset( $_GET['DTT_ID'] ) ? $_GET['DTT_ID'] : $dtt_default;
      $count = EEM_Datetime::instance()->count_related( $dtt_id, 'Checkin', array( array( 'CHK_in' => 1 ) ) );
      echo '<br><div><strong>Checked in Count</strong> ('. $count . ')</div>';
    }
    }
}


Beagle

August 24, 2016 at 6:35 pm

Thank you Josh! It works pretty well, the only thing that might be better is if it wouldn’t keep counting if you check-in/check-out/check-in (result 2 instead of 1), but you have helped me a great deal already. Thanks again,

Mattias


Josh

  • Support Staff

August 25, 2016 at 6:21 am

Hi Mattias,

The reason it counts a check-in/check-out/check-in as 2 check-ins is because checking-out does not negate or delete a check-in that’s been recorded to the database. In other words, the check-in that later got checked-out still happened and should therefore will still be counted.


Beagle

August 25, 2016 at 3:44 pm

Clear and understandable. Thanks, I will close the topic!

The support post ‘Get Check-in Count’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso