Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
andrasguseo / tc-tickets-csv-import.php
Last active May 27, 2025 09:06
ETP > Importing Tickets Commerce Tickets from a CSV File
<?php
/**
* Import tweak to allow importing Tickets Commerce Tickets from a CSV file
*
* Usage: Add the snippet with Code Snippets or to your functions.php file.
* Install and activate WooCommerce.
* Run the ticket import according to https://theeventscalendar.com/knowledgebase/importing-data-from-a-csv-file/
* Confirm the tickets are created.
* Deactivate and delete WooCommerce if not needed
*
@andrasguseo
andrasguseo / functions.php
Created May 12, 2025 10:14
TEC > Next and previous links on the single event page point to the next event in the event's category
<?php
/**
* Next and previous links on the single event page point to the next event in the event's category.
* If an event has no categories, it will show the next event, regardless of any categories.
* If an event has multiple categories, it will show the next event which has any of the categories.
* After that, it will show events having categories of this event.
*
* Usage: Add the snippet with Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
@andrasguseo
andrasguseo / gist:d1011344b1ca497d206575f3443afdbc
Created March 26, 2025 21:55
TEC/ECP > Delete orphaned recurring events after migrating to the new data structure introduced in TEC 6.0
<?php
/**
* Deletes orphaned 'old' recurring events, after the events have been migrated.
* You know you have orphaned events if on the Event admin list the number of All events
* and the number of items don't match.
* @see https://dl.dropbox.com/scl/fi/tmljvc5fzzpr48arklsbt/shot_250326_225112.png?rlkey=dkg0qjh72zhafasnitbrfokv5&dl=0
*
* Creating a database dump before and running a test on a staging site first is recommended!
* Creating a database backup before running the snippet on a production site is recommended!
*
@andrasguseo
andrasguseo / functions.php
Created March 13, 2025 16:17
ET > Delete abandoned orders and related tickets (experimental)
<?php
/**
* Deletes Tickets Commerce Orders and related Tickets/Attendees,
* which are missing a related event or post.
* Creating a database dump before and running a test on a staging site first is recommended.
*
* Usage: Add the snippet with Code Snippets as a "run once" snippet.
* Run the snippet when needed.
*
* @author: Andras Guseo
@andrasguseo
andrasguseo / functions.php
Created March 5, 2025 13:51
TEC > Use space as the thousand separator (TEC only)
<?php
/**
* Format the event cost by using a space as the thousand separator.
*
* Usage: Add the snippet with Code Snippets or to your functions.php file.
* Enter the cost without a thousand separator, when creating the event.
*
* @since March 5, 2025 Initial version.
*
* @param double $cost the event cost
@andrasguseo
andrasguseo / functions.php
Last active February 5, 2025 15:28
ETP + Woo > Autocomplete some orders
<?php
/**
* Set WooCommerce orders for Ticket products to 'completed' status automatically based on certain criteria.
*
* You can further tweak the behavior by adjusting the snippet:
* - based on order status: line 29
* - based on payment gateway: line 36
*/
add_action( 'woocommerce_thankyou', function ( $order_id ) {
// Bail if there is no order.
@andrasguseo
andrasguseo / change-event-time-zone.php
Created January 14, 2025 11:30
TEC > Time zone changer for events
<?php
/**
* Change the time zone of all events and adjust the UTC times accordingly.
*
* Usage: Add the snippet with Code Snippets.
* Set your target time zone on line 20.
* Optional: Set your target time zone abbreviation on line 33.
* Save it as a 'Run once' snippet.
* Go to the Snippet list and click on 'Run' next to the snippet.
*
@andrasguseo
andrasguseo / ea-advanced-category-management.php
Created November 29, 2024 15:29
EA > If an event category is changed locally, don't import the category anymore.
<?php
/**
* When importing from Other URL with Event Aggregator, only import/update the event
* category, if it hasn't been changed on the destination site yet.
*
* Usage: Add the snippet with a plugin like Code Snippets, or to the functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar, Event Aggregator
@andrasguseo
andrasguseo / functions.php
Last active November 7, 2024 22:00
TEC > Block REST API requests coming from EA.
<?php
/**
* Block REST API requests coming from Event Aggregator. Basically blocks imports.
* It can block other sites trying to siphon events with EA through the "Other URL" source.
*
* Usage: Add the snippet with a plugin like Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar
@andrasguseo
andrasguseo / functions.php
Created November 7, 2024 13:16
TEC > Change event content im the subscription feed
<?php
/**
* Changes the event title and description in the iCal feed which is used to export events or
* subscribe to the calendar. Can be used to prank subscribers to the calendar. :)
*
* Usage: Add the snippet with a plugin like Code Snippets or to your functions.php file.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar