Last active
May 5, 2017 18:01
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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