Support

Home Forums Event Espresso Premium Make link (file) available based on Attendee check in status

Make link (file) available based on Attendee check in status

Posted: October 24, 2017 at 12:59 pm


sogtalks@gmail.com

October 24, 2017 at 12:59 pm

I need to make a link to a file display only when an attendee has checked in to a specific event. I went through the documentation but can’t find anything, can you point me in the right direction.

Thank you.


Tony

  • Support Staff

October 25, 2017 at 4:13 am

Hi there,

Where are you looking to show the link?

I’m assuming you have the EE_Registration object?


sogtalks@gmail.com

October 25, 2017 at 11:25 am

I would like to add it to a non-EE account page or I can add it to the expired event details based on user/login/attendance.


Tony

  • Support Staff

October 25, 2017 at 2:17 pm

I would like to add it to a non-EE account page

How are you pulling the correct registration for the user on that page?

You could use the WP user integration add-on to display a list of events:

https://eventespresso.com/wiki/wp-user-integration/#ee4-my-events

Then hook into that add-on and add a link to the actions column based on the check-in status of the event.

Its possible to conditional show a link based on the current check in status, but so far I can’t give you an example as you don’t have the registration object to check against and need a custom solution to pull that in.


sogtalks@gmail.com

October 26, 2017 at 12:41 pm

Tony,

I tried to add the [ESPRESSO_MY_EVENTS] shortcode to an account page that contained a few different chunks of info. The table populated with the correct list but action button was “on” by default and the sub-content was always exposed, not your problem, just and FYI, some conflict with Ultimate member and Paid Membership Pro.

So I simply added a separate page and I get a great table as described. I need some guidance on

Then hook into that add-on and add a link to the actions column based on the check-in status of the event.”

. Any examples around?

Thank you.


Tony

  • Support Staff

October 30, 2017 at 5:41 am

I tried to add the [ESPRESSO_MY_EVENTS] shortcode to an account page that contained a few different chunks of info. The table populated with the correct list but action button was “on” by default and the sub-content was always exposed, not your problem, just and FYI, some conflict with Ultimate member and Paid Membership Pro.

That usually happens when the My Event tables assets (JS and CSS) aren’t loading on the page. Did you add the shortcode directly to the page or using a template with do_shortcode()?

Any examples around?

Not an example of your specific use case, not heres an example of how to add a link to the registrations ticket as a ticket icon:

https://gist.github.com/Pebblo/e56f98451d1aa0964717

And as a quick example of what you may want to do:

https://gist.github.com/Pebblo/08b78a470c74ea1c32b06ade89cc8fd8

Note that the above gists should be considered unsupported and untested, they are a base for you to build your own function.


sogtalks@gmail.com

October 30, 2017 at 3:35 pm

1) I added the shortcode directly to the page. I am okay for now having My Registrations as separate page, works very well and client is happy.

2) The gist …/Pebblo/08b78a470c74ea1c32b06ade89cc8fd8 is what I need, excellent. It works perfectly when I hard-code the URL into the plugin but I am going to use an ACF field so the client can upload the file as part of the edit event page. I assumed that I could replace What do I replace $file_URL with the filed name but that didn’t work?

if( $checked_in_status == EE_Checkin::status_checked_in ) {
				//Set the file URL to use when the user is logged in.
				//This example links to Google, you could use an event meta value.
				$file_url = "certificate_of_attendance";
				//Add the checked in file link to the $actions array.
				$actions['checked_in'] = '<a aria-label="' . __( 'Link to checked in file', 'event_espresso' ) . '" href="' . $file_url. '">'
							. '<span class="dashicons dashicons-media-archive ee-icon-size-18"></span></a>';
			}

The example you sent me is quite elegant, thank you.


Tony

  • Support Staff

October 31, 2017 at 2:59 am

The My Event section has no idea what ‘certificate_of_attendance’ of attendance is, and the code above has no idea what to do with it other than to output it directly to the page.

For ACF you’ll need to use get_field: https://www.advancedcustomfields.com/resources/get_field/

Pass that the meta name and the event ID, which you can get from the registration using:

$EVT_ID = $registration->event_id();

I’d recommend also checking if the get_field function exists first, just in case for some reason ACF is deactivated as your code will then throw a fatal error.


sogtalks@gmail.com

November 1, 2017 at 3:00 pm

Tony,

I worked it out based on your feedback. Thank you.
– I need to hide the icon if there is no file uploaded

//Add a link for only checked in registrations.
function tw_add_checked_in_file_to_my_events( $actions, $registration) {

	
	//Check we have an EE_Registration object.
	if ( $registration instanceof EE_Registration ) {
		//Pull the 'latest' datetime (sorted by date) from the registration.
		$latest_related_datetime = $registration->get_latest_related_datetime();
		//Check we have an EE_Datetime object.
		if( $latest_related_datetime instanceof EE_Datetime) {
			//Pull the checked in status for the current registration using the datetime ID we just pulled in.
			$checked_in_status = $registration->check_in_status_for_datetime( $latest_related_datetime->ID() );
			//Check the checked in status.
			if( $checked_in_status == EE_Checkin::status_checked_in ) {
				//Set the file URL to use when the user is logged in.
				//This example links to Google, you could use an event meta value.

					//Get event ID for this ticket
					$EVT_ID = $registration->event_id();

						//Get the field that holds the URL for the certificate
						$certificate = get_field( 'certificate_of_attendance', $EVT_ID );
		
				$file_url = "$certificate";
				//Add the checked in file link to the $actions array.
				$actions['checked_in'] = '<a aria-label="' . __( 'Link to checked in file', 'event_espresso' ) . '" href="' . $file_url. '" target="_blank">'
							. '<span class="dashicons dashicons-media-archive ee-icon-size-18"></span></a>';
			}
			
		}
		
	}
	return $actions;
}
add_filter( 'FHEE__EES_Espresso_My_Events__actions', 'tw_add_checked_in_file_to_my_events', 10, 2);
//Add a checked in icon to the my events legend.
function tw_add_checked_in_file_to_my_events_legend( $items ) {
	$items['ticket'] = array(
		'class' => 'dashicons dashicons-media-archive',
		'desc' => esc_html__( 'Download Certificate of Attendance', 'event_espresso' )
	);
	
	return $items;
}
add_filter( 'FHEE__status-legend-espresso_my_events__legend_items', 'tw_add_checked_in_file_to_my_events_legend');

Thank you for your help.


Tony

  • Support Staff

November 2, 2017 at 3:27 am

$file_url = "$certificate";

Why do you have quotes around the above? Those should not be needed.

I need to hide the icon if there is no file uploaded

Then check if $file_url is empty before adding the link to the actions.

if( !empty( $file_url ) ) {
   $actions['checked_in'] = '<a aria-label="' . __( 'Link to checked in file', 'event_espresso' ) . '" href="' . $file_url. '" target="_blank">' . '<span class="dashicons dashicons-media-archive ee-icon-size-18"></span></a>';
}


sogtalks@gmail.com

November 2, 2017 at 3:10 pm

Tony,

Why do you have quotes around the above? Those should not be needed.

Inexperienced.

Thank you for your excellent help. All works like a charm now.

FYI – for others
– Series of 4 events per year, same ticket setup, different content
– We have free tickets, an RSVP, for members with paid membership (Paid membership Pro)
– We offer guest tickets as well
– in both cases user must login to RSVP or purchase
– we force login (we have three different Membership/account options)
– non Member cannot RSVP or even see selection option
– event details use Venue display/selection
– event details we added (with People add-on) speaker info/link/photo/blurb using
– event details we added (with ACF) sponsor info/link/logo/blurb
– event details we added (with ACF) “certificate of attendance” document upload file to be available on My Registrations page
– lots of text changes to reflect complexity of “free” RSVP ticket
************
– event archive we added speaker link/photo/blurb
– event archive we added sponsor link/logo
************
– text changes on the Cart/Checkout process
*************
My Registrations page – restrict access/display of certificate document based on Check-in status
************
client using APP for check-ins
************
Client loves mobile access
************
Tested with 1 event – no issues
************
by Company B
************
Event Espresso – Excellent!


Tony

  • Support Staff

November 3, 2017 at 2:45 am

Inexperienced.

Ah, ok. That’s fine, I just thought you had to use them to get it to work which shouldn’t have been the case.

Thank you for your excellent help. All works like a charm now

You’re most welcome, I’m glad it’s working for you 🙂

If you haven’t done so already we’d really appreciate if you could share your EE experience with a review:

https://eventespresso.com/recommend-event-espresso/#review

The support post ‘Make link (file) available based on Attendee check in status’ 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