Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created September 3, 2019 19:07
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/02a8da94581ed96b3f7d63dd104d7416 to your computer and use it in GitHub Desktop.
Save joshfeck/02a8da94581ed96b3f7d63dd104d7416 to your computer and use it in GitHub Desktop.
Add some text that says "Registrations Closed" to Event Espresso's single event, archive events, and calendar views if the event is upcoming but ticket sales have ended
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter('the_title', 'ee_add_on_sale_status_display', 101, 2);
function ee_add_on_sale_status_display($title, $id) {
if(get_post_type($id) == 'espresso_events') {
$html = '';
$tickets = EEH_Event_View::event_tickets_available($id);
if(empty($tickets)) {
$html = '<span class="ee-status small-text '
. 'event-active-status-DTE">'
. 'Registrations Closed'
. '</span>';
}
return $html . $title;
}
return $title;
}
add_filter(
'FHEE__EE_Calendar__get_calendar_events__tooltip_reg_btn_html',
'my_custom_calendar_tooltip_custom_text',
10,
3
);
function my_custom_calendar_tooltip_custom_text(
$output,
$event,
$datetime
) {
if($event instanceof EE_Event) {
$tickets = EEH_Event_View::event_tickets_available($event->id());
if(empty($tickets)) {
$output = '<div class="sold-out-dv">Registration Closed</div>';
}
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment