Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / my_custom_checkboxes_for_primary_question_groups.php
Last active January 8, 2024 23:44
Check a question group box by default. For the Event Espresso 4 event editor. Primary Question group ID 3.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_action( 'AHEE_event_editor_questions_notice', 'my_custom_checkboxes_for_primary_question_groups' );
function my_custom_checkboxes_for_primary_question_groups() {
echo '<script>jQuery(
"#espresso_events_Registration_Form_Hooks_Extend_primary_questions_metabox input[value=\'3\']"
)
.prop( "checked", true );</script>';
}
@joshfeck
joshfeck / set_country_option_with_a_default.php
Last active June 1, 2023 19:59
Make the Country field default to US and State field default to North Carolina. Event Espresso 4 Registration form step.
<?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',
'my_change_default_ee_country_option',
20
);
function my_change_default_ee_country_option(){
$custom_js = 'jQuery(document).ready(function($){';
@joshfeck
joshfeck / content-espresso_events-shortcode.php
Created April 16, 2020 16:36
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
<?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 / canada_taxes.php
Created April 16, 2020 19:35
GST, HST, PST, and QST for Canada eh? Event Espresso 4.
<?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 / percentage_surcharge.php
Created February 16, 2017 19:16
Adds a percentage surcharge line item to an Event Espresso transaction, the percentage will be based on the answer of a question on the registration form. Variation of https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_ee_apply_transaction_surcharge.php
<?php
/**
* PLEASE READ AND FOLLOW ALL INSTRUCTIONS IN CAPS
*
* IN ORDER FOR THIS TO WORK YOU NEED TO ADD A CUSTOM QUESTION
* BY LOGGING INTO THE WORDPRESS ADMIN AND GOING TO :
* Event Espresso > Registration Form
* AND THEN CLICKING ON "Add New Question"
* FOR THIS EXAMPLE CODE I CREATED A QUESTION NAMED "Billing Address Province"
* SET ITS TYPE TO "Dropdown" AND GAVE IT THE FOLLOWING TWO OPTIONS:
@joshfeck
joshfeck / add_currency_code_spco.php
Last active January 27, 2023 14:55
Add currency code to the checkout display in Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function my_ee_add_currency_checkout() {
wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).one( "ajaxStop", function() {
jQuery("#spco-payment-info-table")
.find(".spco-grand-total td:contains(\'$\')")
.append("<span>(USD)</span>");
@joshfeck
joshfeck / exclude_events.php
Created February 27, 2021 03:32
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.
<?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 / example_csv.php
Created September 11, 2018 21:35
Remove registrations with "Cancelled" status. 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__EE_Export__report_registration_for_event',
'my_exclude_cancelled_registrations_csv_report',
10,
2
);
function my_exclude_cancelled_registrations_csv_report(
@joshfeck
joshfeck / ical_offset_example.php
Created October 24, 2018 18:13
Add a simple one-hour offset to the times included in the iCal data, if a custom field value is present. Useful for sites that have events in different timezones
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EED_Ical__download_ics_file_ics_data',
'my_custom_ical_timezone_output_filter',
10,
2
);
@joshfeck
joshfeck / ee_add_unique_email_validation.php
Created February 25, 2017 20:28
Add custom email field input validation to check for unique email addresses for each field. You can add this to a site specific plugin.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_add_unique_email_validation(){
wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).ready(function($) {
$(".ee-reg-qstn-email").addClass("unique");
$.validator.addMethod("unique", function(value, element) {
var parentForm = $(element).closest("form");