Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
andrasguseo / ticket-limits.php
Created March 8, 2024 11:55
ET > Set ticket limits based on event post ID.
<?php
/**
* Set ticket limits based on event post ID.
*
* Usage:
* - Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author Andras Guseo
*
* Plugins required: Event Tickets
@andrasguseo
andrasguseo / recurrence-end-date.php
Created March 5, 2024 11:39
ECP > Set recurring event end date
<?php
/**
* Change the end date for recurring events from 1 year in the future to something else.
* IMPORTANT: Works with Classic Editor only!
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author Andras Guseo
*
* Plugins required: Events Calendar Pro
@andrasguseo
andrasguseo / location-search-autocomplete.php
Created March 5, 2024 10:55
ECP > Autocomplete for location search
<?php
/**
* Autocomplete for location search. Work in progress.
* Requirements:
* - Custom Google Maps API key (https://theeventscalendar.com/knowledgebase/setting-up-your-google-maps-api-key/)
* - Enable the Places API in Google Cloud Console (https://console.cloud.google.com/apis/dashboard)
* - Setting up API key restrictions is recommended! (https://theeventscalendar.com/knowledgebase/using-google-maps-api-key-restrictions/)
* - The Places API restriction should be added to the JavaScript map displays restrictions.
*
* IMPORTANT: Using the Google Maps API and the Places API can incur costs!!!
@andrasguseo
andrasguseo / tickets.php
Created February 8, 2024 10:57
ET > Template override for the tickets block - Hide tickets block when logged in user already has a ticket.
<?php
/**
* Block: Tickets
*
* This template override will hide the tickets block, if the logged in user
* has already purchased a ticket for the given event.
* For it to work the following setting has to be enabled:
* Tickets > Settings > General > Require users to log in before they purchase tickets
*
* This is a template ovverride for the following file:
@andrasguseo
andrasguseo / ticket-step-modifier.php
Last active February 7, 2024 18:27
ET > Make a ticket quantity selector step by 2
<?php
/**
* Make a ticket quantity selector step by 2.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author: Andras Guseo
*
* Plugins required: Event Tickets
* Created: February 7, 2024
@andrasguseo
andrasguseo / event-title-target.php
Created February 6, 2024 14:52
TEC > Set a target for the event title
<?php
/**
* Set a target for the event title.
* The code adds a custom field for events where you can select the link target.
* A template override for each calendar view is needed where you want this implemented.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets
*
* @author: Andras Guseo
*
@andrasguseo
andrasguseo / show-for-first-attendee-only.php
Last active January 30, 2024 21:06
ET+ > Show Attendee Registration Field for first attendee only.
<?php
/**
* Show Attendee Registration Field for first attendee only.
* (Hide field for subsequent attendees.)
* Can handle multiple fields.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author: Andras Guseo
*
@andrasguseo
andrasguseo / show-lat-long.php
Created January 29, 2024 23:33
CE > Show input for lat/long coordinates on the venue editing page in Community Events
<?php
/**
* Show input fields for lat/long coordinates on the venue editing page in Community Events.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author: Andras Guseo
*
* Plugins required: The Events Calendar, Events Calendar Pro, Community Events
* Created: January 29, 2024
@andrasguseo
andrasguseo / tec-open-filterbar.php
Last active January 23, 2024 14:59
Filter Bar > Open the Filter Bar on mobile on initial pageload
<?php
/**
* Open the Filter Bar on mobile on initial pageload.
*
* By default, Filter Bar is closed on mobile regardless of the setting.
* With this snippet Filter Bar will show on pageload when using the horizontal setup.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @author: Andras Guseo
@andrasguseo
andrasguseo / tec-ea-maybe-remove-eventurl.php
Created January 18, 2024 21:20
EA > Remove the Event URL when it's the same as the source URL
<?php
/**
* Remove the Event URL when it's the same as the source URL.
*
* When importing from OtherURL and the EventURL field is empty, it will be filled with the
* URL of the source site by default. This snippet makes sure it stays empty.
*
* Usage: Add the snippet to your functions.php file or with a plugin like Code Snippets.
*
* @param array $event Event data to save