Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / exclude_events.php
Created Feb 27, 2021
Exclude events from event lists using a tag. In this example, any events with the tag "exclude" will not be included in front end event lists. Event Espresso 4.
View exclude_events.php
<?php // only add this opening PHP tag if starting with a new file with no opening PHP tag
add_filter( 'posts_where', 'ee_remove_hidden_tagged_event_list', 25, 2 );
function ee_remove_hidden_tagged_event_list( $SQL, WP_Query $wp_query ) {
global $wpdb;
$tag = get_term_by( 'slug', 'exclude', 'post_tag' );
if( $tag instanceof WP_Term ) {
$tag_id = $tag->term_id;
} else {
return $SQL;
@joshfeck
joshfeck / shortcode_example.php
Last active Feb 16, 2021
A shortcode to display EE4 events in a similar way that EE3 did. With the Smoothness jQuery UI styles. Add this code to a site-specific plugin, activate it, then add [espresso_legacy_events] to a WordPress page or post.
View shortcode_example.php
<?php // only add this opening PHP tag if starting with a new file with no opening PHP tag
function my_ee_legacy_events_shortcode($args) {
if(!class_exists('EventEspresso\core\domain\services\wp_queries\EventListQuery')){
return;
}
global $wp_scripts;
// get registered script object for jquery-ui
$ui = $wp_scripts->query('jquery-ui-core');
@joshfeck
joshfeck / ical_reminder.php
Last active Feb 16, 2021
Add a reminder at 60 minutes before event's datetime start. Event Espresso 4.
View ical_reminder.php
<?php // open PHP tag must be omitted if adding the following code to an existing PHP file that already has an opening PHP tag
add_filter(
'FHEE__EED_Ical__download_ics_file_ics_data',
function(
$ics_data, $datetime
) {
$ics_data['BEGIN'] = "VALARM";
$ics_data['TRIGGER'] = "-PT60M";
$ics_data['ACTION'] = "DISPLAY\r\nDESCRIPTION:Reminder";
@joshfeck
joshfeck / organizer_event_linked_data.php
Created May 1, 2020
Add "organizer" linked data to event schema markup. Event Espresso 4
View organizer_event_linked_data.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'AHEE__json_linked_data_for_event__template',
'my_organizer_to_linked_data_for_event'
);
function my_organizer_to_linked_data_for_event() {
$o_name = get_post_meta(get_the_ID(), 'organizer_name', true);
@joshfeck
joshfeck / cancelled_regs.php
Last active May 1, 2020
Removed cancelled registrations from default view. Event Espresso 4 Registrations admin page
View cancelled_regs.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__Registrations_Admin_Page___get_where_conditions_for_registrations_query',
'jf_ee_reg_list_table_reg_status_where',
11,
2
);
function jf_ee_reg_list_table_reg_status_where(
@joshfeck
joshfeck / expired-event-message.php
Created Apr 23, 2020
Show a message when it's an expired event. Event Espresso 4.
View expired-event-message.php
<?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_event_date',
function($post) {
$event = EEH_Event_View::get_event($post->id);
$status = $event instanceof EE_Event ? $event->get_active_status() : '';
if ($status == 'DTE') {
echo '<h4>This event is expired and not part of the 2020 schedule.</h4>';
@joshfeck
joshfeck / stripe_desc_email.php
Created Apr 22, 2020
Append the primary registrant's email address to the end of the Stripe order description. Event Espresso 4.
View stripe_desc_email.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EEG_Stripe_Onsite__doDirectPaymentWithPaymentIntents__payment_intent_data',
'stripe_elements_cf_order_desc_email',
10,
4
);
function stripe_elements_cf_order_desc_email(
@joshfeck
joshfeck / canada_taxes.php
Created Apr 16, 2020
GST, HST, PST, and QST for Canada eh? Event Espresso 4.
View canada_taxes.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
/**
* PLEASE READ AND FOLLOW ALL INSTRUCTIONS IN CAPS
*
* IN ORDER FOR THIS TO WORK YOU NEED TO ACTIVATE THE "ADDRESS QUESTION GROUP"
* THEN SET THE STATE/PROVINCE QUESTION TO BE REQUIRED
*
* BECAUSE THIS QUESTION SHOULD ONLY BE ASKED ONCE PER TRANSACTION
@joshfeck
joshfeck / content-espresso_events-shortcode.php
Created Apr 16, 2020
Example of a custom template for the [ESPRESSO_EVENTS] shortcode. You can upload this to your WP child theme or into /wp-content/uploads/espresso/templates
View content-espresso_events-shortcode.php
<?php
/**
* This template will display a list of events - copy it to your theme folder
*
* @ package Event Espresso
* @ author Seth Shoultes
* @ copyright (c) 2008-2013 Event Espresso All Rights Reserved.
* @ license http://eventespresso.com/support/terms-conditions/ * see Plugin Licensing *
* @ link http://www.eventespresso.com
* @ version 4+
@joshfeck
joshfeck / auto-fill_country_stripe.php
Created Apr 14, 2020
Auto-fill County in billing form for Stripe. Event Espresso 4
View auto-fill_country_stripe.php
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// remove "add new state microform" from billing form
add_action(
'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
function() {
remove_filter(
'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
array(