Filters
First, be aware that this article is aimed at advanced users / developers. The plugin already has many ways of filtering, selecting and displaying events, please don’t confuse the plugin ability to filter with WordPress filters.
Before resorting to start coding to apply WordPress Filters check that there is not already a way of getting the same results with a standard plugin feature. Across all plans there are already more than 80 options that require no code.
See the detailed options for selecting and filtering Eventbrite display here
WordPress Filters
WordPress Filters are snippets of code that allow you to pass data through, they are used to enable overriding data used in plugins and themes. This plugin has several features allowing you to customise some aspects. Normally filters are applied to customise themes by inserting the code into a child theme’s functions.php.
Not sure how to add PHP code? See this article about adding PHP snippets.
WordPress Filters in Free
Event Data
After the data is retrieved from the API or cache, the returned data set can be filtered. This could be used to make custom changes or to add event data from different sources.
filter: (‘wfea_api_results‘ , $events, $atts )
This slightly complex example changes the end date on events that are over several day so on calendar layouts they appear as a single bookable day.
Widget Content
The widget uses the excerpt by default. This is normally Ok but can be filtered by other plugins. There is a filter in the template that allows this to be adjusted.
filter: (‘eawp_excerpt‘ , $excerpt)
If you want to create a custom plugin it would look like
And if you just want to download this and install – then use this link to get the zip file
Event URL
This filter allows you to adjust the event URL. This is primarily so you can add tracking information to your link – see https://www.eventbrite.com/support/articles/en_US/How_To/how-to-create-promotional-tracking-links?lg=en_GB
Simplest usage would be
add_filter( 'wfea_event_url', function ( $url) { return $url . '?aff=affiliate1'; });
Optionally you can apply logic based on additional data, for example
add_filter( 'wfea_event_url', function ( $url, $event_id, $organizer, $venue, $category ) { $code = 'online'; if ( property_exists( $venue, 'id' ) ) { switch ( $venue->id ) { case 12345: $code = 'venue1'; break; case 999893: $code = 'venue2'; break; default: $code = 'general'; } } return $url . '?aff=' . $code; }, 10, 5 );
Cache Time
The free version has a cache time of 24 hours, for most uses this is fine as events are not normally added quickly, except during initial setup.
The pro version does have Cache settings however if you are unable to use the Pro version you can change the cache time time is the free version via this filter.
filter: (‘wfea_eventbrite_cache_expiry‘ , $seconds)
add_filter( 'wfea_eventbrite_cache_expiry', function ( $seconds ) {
return 3 * HOUR_IN_SECONDS;
}, 10, 1 );
Combined Date – Time Format
The combined date / time format appears in several layouts and typically looks like 12/02/2019, 10:00 – 11:00
filter: (‘wfea_combined_date_time_time_format‘ , $format)
$format defaults to your settings -> general -> time format
example: include am / pm
add_filter( 'wfea_combined_date_time_time_format', function ( $format ) { return 'g:i a'; }, 10, 1 );
filter: (‘wfea_combined_date_time_date_format‘ , $format)
$format defaults to your settings -> general -> date format, plus a , and space
example: display like 16th January
add_filter( 'wfea_combined_date_time_date_format', function ( $format ) { return 'jS F'; }, 10, 1 );
Date formats are documented here https://wordpress.org/support/article/formatting-date-and-time/
filter: (‘wfea_event_time‘ , $event_time, $start, $end)
Override totally
add_filter( 'wfea_event_time', function ( $event_time, $start, $end ) { // do you stuff to update $event_time return $event_time; }, 10, 1 );
filter: (‘wfea_eventbrite_event_start‘ , $start)
Do something with the local start time
add_filter( 'wfea_eventbrite_event_start', function ( $start ) { // do you stuff to update $start return $start; }, 10, 1 );
filter: (‘wfea_eventbrite_event_end‘ , $end)
Do something with the local end time
add_filter( 'wfea_eventbrite_event_end', function ( $end ) { // do you stuff to update $end return $end; }, 10, 1 );
Extra WordPress Filters in Pro
filter: (‘wfea_price_display‘ , $price_display, $min, $max, $currency)
Do something with the price display
add_filter( 'wfea_price_display', function ( $price_display, $min, $max, $currency) { // do you stuff to update $end return $price_display; }, 10, 4 );
filter: (‘wfea_currency_symbol‘ , $symbol, $currency)
Change the symbol for a currency. Evenbrite currencies are ISO e.g. USD
add_filter( 'wfea_currency_symbol', function ( $symbol, $currency) { // do you stuff to update the symbol return $symbol; }, 10, 2 );
filter: (‘wfea_availability_display‘ , $msg, $total_sold, $event_capacity)
Do something with the ticket availability display
add_filter( 'wfea_availability_display', function ( $msg, $total_sold, $event_capacity) { // do your stuff change $msg return $msg; }, 10, 3 );
filter: (‘wfea_age_restriction‘ , $output, $age)
Do something with the age restriction display display. e.g. all_ages by defualt displays nothing, if you want some text you can use this filter
add_filter( 'wfea_age_restriction', function ( $output, $age) {
// do your stuff change $output
if ( 'all_ages' === $age ) {
$output = 'No Age Restriction';
}
return $output;
}, 10, 2 );
filter: (‘wfea_single_event_slug‘ , $slug)
by default the single event pretty permalink is identified by /e/. If /e/ causes conflicts with existing pages or links you can filter this to something else e.g. /eb_event/. After applying a change you need to refresh permalinks, do this via Tools>Permalinks and SAVE.
add_filter('wfea_single_event_slug', function() { return 'eb_event'; });
add_filter('wfea_get_tags', '__return_true');