Support

Home Forums Event Espresso Premium Accessing checked-in data from event QR code AND manually checking from the App

Accessing checked-in data from event QR code AND manually checking from the App

Posted: June 26, 2023 at 7:17 am

Viewing 17 reply threads


ChiroEurope

June 26, 2023 at 7:17 am

I have an event cron activated by an event having the QR codes scanned by attendees to check in. This data is then sent on for an email. We just realised that attendees who are checked in manually on the app do not populate the database for the event cron, and my IT is wondering where this can be accessed so it can also be used for the email.


Tony

  • Support Staff

June 26, 2023 at 7:25 am

Hi there,

What are they currently using to ‘trigger’ the cron currently?

A hook within EE?


ChiroEurope

June 26, 2023 at 10:37 am

Ahh, as far as I know it is the scanning of a QR code that triggers the cron. Since we have events without using tickets and they dont need the cron email. Specifically I dont know more than that. I will ask.


Tony

  • Support Staff

June 27, 2023 at 5:28 am

I’ll explain my thinking here as it’ll make sense as to why I’m asking.

A cron is just a schedule, it’s a way to say “every X amount of time do Y function”.

Your task is “This data is then sent on for an email.” which doesn’t really make sense to use a cron for if you are doing that on EVERY scan. If its an email that bulk sends details for all checked-in/out registrations every X hours/days etc then that does make sense to use a cron however, it then doesn’t make sense as to why only check-ins through the app are working. Manual check-ins change the same data so I’m not sure how they are pulling the data in but manual check-ins and scanning the barcode to check-in change the same check-in record so it could be a case of using the wrong hook or searching for the wrong data, I don’t know without details of the code they are using.


ChiroEurope

June 29, 2023 at 1:02 am

Completely logical, the reason we set it up was to create attendance certificates which isn’t part of EE. So we use the Ticket Add-on, and us the check-in feature to trigger the cron. The custom code then runs the populated custom table to send an email / attendance certificate 5 days after event closure.

No hook is used, but it seems the QR code was the main trigger. I discovered this anomaly as i set up a test event and only manually checked (myself) in (also using this to test the other URL issue i was having with the App). The use of the manual check in did not trigger the cron. I‘m making the assumption that if I had scanned a QR code it would have.

There is a big time zone difference between you and my IT, so I am also wondering if I need to set up a new test event, and check in attendees using both methods and see what happens.

In the meantime I am waiting on a response to see if I can send you the code that triggers the cron.


Tony

  • Support Staff

June 29, 2023 at 2:15 am

My guess is if you set up a new event and have a manually checked in and barcode scanned registrant you’ll get both. I’m assuming the scan is setting up the cron for the event itself… but just guessing based on how I think it would work.

Doesn’t hurt to try it so I’d set that up to test in the meantime personally 🙂


ChiroEurope

July 7, 2023 at 4:49 am

This reply has been marked as private.


Tony

  • Support Staff

July 7, 2023 at 5:29 am

Hi there,

Unless I’m missing something, that’s not using a cron.

It’s using the request sent from the app itself which checks in the user to trigger an email on that same request, not on a cron.

So the reason it’s not working for ‘manual’ check-ins is because the manual check-ins do not contain the same data in the request (it’s not needed for those), so this:

$_REQUEST[‘where’][‘OR’][‘REG_code’]

Is not set on those manual check-in requests.

There are a couple of notes on that code, the developer isn’t using our model system in that code, which isn’t the end of the world, but the models take a lot of the work out of the above for you once you get to know how to use them.

I don’t know what hook (if any) that code is running on, but there’s a dynamic hook within Event Espresso that fires when a registration is checked-in/out:

do_action("AHEE__EE_Registration__toggle_checkin_status__{$checked_status}", $this, $DTT_ID);

(Search the EE codebase to find it)

If they wanted to trigger an email only when a registration is checked in, just hook into AHEE__EE_Registration__toggle_checkin_status__checked_in, they’ll still need to check if there is a previously check-in record, which leads onto…

Looks like they are using a custom table to track if a registration has been checked in, we already have that within core. The EE_Registration object (which is passed in the above hook) has multiple methods for checkins, for example check_in_status_for_datetime() they can also get all the Attendee data and anything else related to the registration from that.

I highly recommend they take a look at the model docs: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

A lot of what they are doing within that code can be handled by the models easier and without custom tables (although I have no idea if that table is used elsewhere but again even that could likely be handled using our models to get what is needed there), the hook I mentioned removes the ‘working on X but not on Y requests’.


ChiroEurope

July 7, 2023 at 6:04 am

Thanks for your quick & thorough reply – I’ve forwarded this onto them. I have no idea 🙂


Tony

  • Support Staff

July 7, 2023 at 6:12 am

You’re most welcome 🙂


ChiroEurope

July 24, 2023 at 6:53 am

Original thread: https://eventespresso.com/topic/accessing-checked-in-data-from-event-qr-code-and-manually-checking-from-the-app/#post-345158

My IT has been unable to find the correct hook where manually arrived attendees are checked in. The hook for QR attendees is fine, but for whatever reason this appears not to include manually checked in. We need a single hook for both.

The previous thread had lots of info from Tony, but apparently was not sufficient to resolve the question. TIA


Tony

  • Support Staff

July 24, 2023 at 5:45 pm

Hi there,

The info I gave you in the previous post is pretty much exactly what you are asking for here:

AHEE__EE_Registration__toggle_checkin_status__checked_in

Is a hook that will fire whenever a registration is checked in be that automatically, through the app, manually or any other way.

When the checked-in status is switched to checked_in, that hook ‘fires’.

Is there something specific they are struggling with when using that hook?


ChiroEurope

July 24, 2023 at 11:32 pm

I figured that was the case, but for whatever reason they seem unable to make it work. I wanted to keep the other thread going but it was closed off. Thank you and I shall pass this on and see how it goes…


Tony

  • Support Staff

July 25, 2023 at 2:44 am

I figured that was the case, but for whatever reason they seem unable to make it work.

If they can provide more details I may be able to help.

What issue are they running into when using that hook?

I wanted to keep the other thread going but it was closed off.

Threads automatically close when there are no replies within 14 days.

I’ll re-open it and merge this one into it.


ChiroEurope

July 27, 2023 at 5:24 am

This reply has been marked as private.


Tony

  • Support Staff

July 27, 2023 at 6:29 am

So still not using our models to make this easier for some reason and duplicating queries due to not using the models.

Excluding the check for an existing check-in record, an email can be triggered using that hook simply using:

add_action('AHEE__EE_Registration__toggle_checkin_status__checked_in', 'tw_ee_custom_email_when_checked_in', 10, 2);
function tw_ee_custom_email_when_checked_in( $registration, $DTT_ID ) {
   
   $attendee = $registration->attendee();
   
   $data=array(
      'att_name' => $attendee->full_name(),
      'att_id' => $attendee->ID(),
      'att_email' => $attendee->email(),
      'event_id' => $registration->event_ID(),
      'status' => '0'
   );

   $headers = array();
   $headers[] = "From: test@test.com" . "\r\n";
   $headers[] = 'Content-Type: text/html; charset=UTF-8';
   $email_body = '<p>Hello,'.print_r($data,true).'</p>';
   wp_mail('test@test.com', "Testing Email",$email_body , $headers);

}

The current EE_Registration object is passed to the filter, so it doesn’t need to pulled from the database again using the registration ID.

$registration->attendee(); handles pulling in the related attendee (EE_Contact).

Theres a bunch of ‘getters’ on both of those objects to get all the info they would need, like full_name(), ID(), email() on the attendee.

I’ve tested the above and it triggers and email when manually checking in and through the app.

Checking for a previous check-in record I’ll leave to the developer as otherwise I’m basically writing the custom function for them, if they learn how to use the model system it’s relatively straightforward.


ChiroEurope

August 1, 2023 at 11:59 pm

Ok. Thanks for that. I passed it on. Not knowing code doesn’t help Me, them not following your advice even less. Tia


Tony

  • Support Staff

August 2, 2023 at 5:41 am

My sympathies, I know your the middle man here and that must be frustrating for you 🙂

But, even without knowing the code in use it’s likely you can see yourself how using the models makes this much easier. 7 lines of code above to pull in the registration, then the attendee, replaced with simply:

$attendee = $registration->attendee();

which is using the registration object passed to the filter to pull in the related attendee…. DONE.

Then just using $attendee to pull in all the data they need.

The difference is they need to lead a little about our model system to use it but that quickly pays off the more they work with EE.

Anyway, I’m rambling 🙂 any further questions just let me know.


ChiroEurope

August 2, 2023 at 10:41 pm

So they redid the code with the following, and tell me that it still does not pull in manually check-in people.

add_action('AHEE__EE_Registration__toggle_checkin_status__checked_in', 'tw_ee_custom_email_when_checked_in', 10, 2);
function tw_ee_custom_email_when_checked_in( $registration, $DTT_ID ) {
	$attendee = $registration->attendee();
	$data=array(
	'att_name' => $attendee->full_name(),
	'att_id' => $attendee->ID(),
	'att_email' => $attendee->email(),
	'event_id' => $registration->event_ID(),
	'status' => '0'
	);
	$headers = array();
	$headers[] = "From: test@test.com" . "\r\n";
	$headers[] = 'Content-Type: text/html; charset=UTF-8';
	$email_body = '<p>Hello,'.print_r($data,true).'</p>';
	wp_mail('developondemand@gmail.com', "Testing Email",$email_body , $headers);
}


Tony

  • Support Staff

August 3, 2023 at 4:12 am

I know you’re stuck in the middle here, but that’s an exact copy of my code with no other change than to add their email address in the to field of wp_mail().

That code works for me:

https://monosnap.com/file/5xhNSEp4TVcbvO9PFP916KmtkoA7aG

That video has the code set on the site, showing the WP Mail log with no emails, me manually checking in a registrant and refreshing the mail log to confirm an email triggered.


ChiroEurope

August 8, 2023 at 12:49 pm

It may seem hard to believe, but it worked! Thank you for your patience and assistance as always.

In the process of testing the manual checkin something odd did happen though. A login on my mobile worked fine, on the IT’s mobile device not. Tried several things but was never able to get them to be able to log in. Any logical reason why that might have occurred ?


Tony

  • Support Staff

August 8, 2023 at 6:01 pm

It may seem hard to believe, but it worked!

Haha, nope, using the correct hook is a great leap forward. Using the models then just make things easier 🙂

Thank you for your patience and assistance as always.

You’re most welcome.

In the process of testing the manual checkin something odd did happen though. A login on my mobile worked fine, on the IT’s mobile device not. Tried several things but was never able to get them to be able to log in. Any logical reason why that might have occurred ?

There’s lof of reasons this can happen.

You mentioned mobile so I assume you mean through he EE4 Mobile apps and not logging into the site itself?

Viewing 17 reply threads

The support post ‘Accessing checked-in data from event QR code AND manually checking from the App’ 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