Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Last active May 5, 2017 18:01
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/d4ddcd2f2d25732d7a666123ab99a4e5 to your computer and use it in GitHub Desktop.
Save joshfeck/d4ddcd2f2d25732d7a666123ab99a4e5 to your computer and use it in GitHub Desktop.
Display count of datetime registrations (sold + reserved) on event listings where datetimes are shown
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__espresso_list_of_event_dates__datetime_html',
'my_add_sold_of_reg_limit_message',
10,
2
);
function my_add_sold_of_reg_limit_message( $html, $datetime ) {
$html .= '<br><span class="space-remain">';
$html .= $datetime->sold_and_reserved();
$html .= ' of ';
$html .= $datetime->reg_limit();
$html .= ' attendees total</span>';
return $html;
}
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_details_after_the_content', 'my_event_registration_count' );
function my_event_registration_count( $post ) {
$event_obj = $post->EE_Event;
$html = '';
if ( $event_obj instanceof EE_Event ){
$reg_count = EEM_Event::instance()->count_related(
$event_obj,
'Registration',
array(
array(
'STS_ID' => array(
'NOT_IN',
array(
EEM_Registration::status_id_cancelled
)
)
)
)
);
$html .= '<strong>';
$html .= $reg_count;
$html .= ' of ';
$html .= $event_obj->total_available_spaces();
$html .= ' attendees total</strong>';
}
echo $html;
}
@joshfeck
Copy link
Author

joshfeck commented May 2, 2017

You can add the above to a functions plugin or into your WordPress theme's functions.php file.

See also:
https://gist.github.com/joshfeck/f706dd0c1d315289c7293b24a5fa9c02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment