Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created November 11, 2016 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/7543350476b18b2b4a5f98f8202b89a3 to your computer and use it in GitHub Desktop.
Save joshfeck/7543350476b18b2b4a5f98f8202b89a3 to your computer and use it in GitHub Desktop.
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