Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wrap contents of the Event Espresso Thank You page with a div, and include a category class name if there's a category set on the event.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE__thank_you_page_overview_template__top', 'my_custom_div_class_thank_you_page' );
function my_custom_div_class_thank_you_page( $transaction ) {
if ( $transaction instanceof EE_Transaction ) {
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
if ( $event instanceof EE_Event ) {
$events[ $event->ID() ] = $event;
$category = $event->first_event_category();
if ( $category instanceof EE_Term ) {
$category_slug = $category->slug();
echo '<div class="' . $category_slug . '">';
} else {
echo '<div class="no-category">';
}
}
}
}
}
}
add_action( 'AHEE__thank_you_page_overview_template__bottom', 'my_closing_div_thank_you_content' );
function my_closing_div_thank_you_content( $transaction ) {
if ( $transaction instanceof EE_Transaction ) {
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
if ( $event instanceof EE_Event ) {
echo '</div><!-- end category -->';
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.