Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / cpt_archive_events_posts_orderby.php
Created October 21, 2019 17:36
Set /events/ archive to use WordPress defaults for posts orderby. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter('pre_get_posts', 'order_event_archive_by_wp_default');
function order_event_archive_by_wp_default($query) {
if ( $query->is_archive &&
isset($query->query['post_type']) &&
$query->query['post_type'] == 'espresso_events')
{
$CPT_Event_Strategy = EE_Registry::instance()->load_core('EE_CPT_Event_Strategy');
@joshfeck
joshfeck / add_user_cap.php
Last active March 30, 2022 10:38
Add a new capability to WP User account after they complete a registration for a specific event. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action(
'AHEE__EE_Transaction_Processor__update_transaction_and_registrations_after_checkout_or_payment',
'my_add_user_cap_for_event',
10,
2
);
@joshfeck
joshfeck / venue-location.php
Created September 30, 2019 23:12
Change "venue" to "location", and other variations of the term. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter( 'gettext', 'ee_venue_filter_gettext', 10, 3 );
function ee_venue_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Venue' => 'Location',
'Venue:' => 'Location:',
@joshfeck
joshfeck / conditional_question.php
Created September 25, 2019 18:38
An example that shows how to conditionally not include a registration form question when a specific ticket is in the cart. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'wp_enqueue_scripts', 'rc_ee_hide_custom_questions_convention', 99 );
function rc_ee_hide_custom_questions_convention() {
wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).ready( function( $ ) {
if($("#spco-attendee_information-dv").find(".spco-attendee-ticket-910").length !== 0) {
$(".ee-reg-qstn-34-input-dv").hide();
@joshfeck
joshfeck / invoice_icon_remove.php
Created September 24, 2019 18:17
Remove the invoice icon from the actions column of the my events page. Event Espresso 4 + WP Users add-on
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EES_Espresso_My_Events__actions',
'my_remove_invoice_from_column',
10,
2
);
function my_remove_invoice_from_column(
@joshfeck
joshfeck / re-order.php
Created September 12, 2019 15:37
Post Types Order for Event Espresso 4. Companion to the Post Types Order plugin. This plugin adds a page to re-order Event Espresso events
<?php
/*
Plugin Name: Post Types Order for Event Espresso
Description: Companion to the Post Types Order plugin. This plugin adds a page to re-order Event Espresso events
Author: Event Espresso support staff
Version: 1.0
*/
add_filter(
'FHEE__EE_Register_CPTs__get_CPTs__cpts',
'ee_modify_show_ui_for_events_cpt'
@joshfeck
joshfeck / custom_column_registrations.php
Last active September 6, 2019 14:31
Adds a "Transaction Number" column to the Event Espresso > Registrations page. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE_manage_event-espresso_page_espresso_registrations_columns',
'my_filter_registration_list_table_columns',
10,
2
);
add_action(
@joshfeck
joshfeck / adjacent_posts_filter.php
Created September 6, 2019 01:24
Change the next and previous post links sort order and filter out expired events for single espresso_events post types. Requires EE4 + a theme that uses the native next_post_link() and previous_post_link() functions.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'template_redirect', 'ee_custom_filtered_adjacent_post' );
function ee_custom_filtered_adjacent_post() {
add_filter( 'get_next_post_join', 'ee_custom_filtered_adjacent_post_join' );
add_filter( 'get_previous_post_join', 'ee_custom_filtered_adjacent_post_join' );
add_filter( 'get_next_post_where', 'ee_custom_filtered_adjacent_post_where' );
add_filter( 'get_previous_post_where', 'ee_custom_filtered_adjacent_post_where' );
@joshfeck
joshfeck / ticket_sales_ended.php
Created September 3, 2019 19:07
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 '
@joshfeck
joshfeck / calendar_tooltip.php
Created August 27, 2019 16:39
Change display of attendee limit text in Event Espresso 4's calendar tooltip
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EE_Calendar__get_calendar_events__tooltip_reg_btn_html',
'my_custom_calendar_available_spaces',
10,
3
);
function my_custom_calendar_available_spaces(