Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / custom_functions.php
Created July 26, 2013 20:41
Here are a few custom functions you can place in Event Espresso's custom_functions.php file to override the default email behavior when sending out registrations for free events that were registered via Multi Event Registration. Please note, this code has only been tested to work in cases where all the events are free. What it will do is concate…
<?php
function msec_email_by_session_id($session_id, $send_attendee_email = TRUE, $send_admin_email = TRUE, $multi_reg = FALSE) {
global $wpdb;
$sql = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE attendee_session = %s";
$attendees = $wpdb->get_col( $wpdb->prepare( $sql, $session_id ));
$admin_email_params = array('email_body'=>'');
foreach ($attendees as $attendee_id) {
$data = espresso_prepare_email_data($attendee_id, $multi_reg);
if ($send_attendee_email == 'true') {
$attendee_email_params = espresso_prepare_email($data);
@joshfeck
joshfeck / tracking_code_example.php
Created July 30, 2013 21:27
A few functions that will allow you to insert tracking code into the head of the document on the single registration page. You can substitute the hook if you want the tracking code to go on another page. Requires WordPress + Event Espresso 3.x Support forum post: http://eventespresso.com/topic/is-there-a-way-to-insert-tracking-codes-in-within-th…
<?php
add_action ( 'action_hook_espresso_social_display_buttons', 'itc_add_tracking_code_hook');
add_action ( 'wp_head', 'itc_print_tracking_code' );
function itc_add_tracking_code_hook () {
global $add_my_tracking_code;
@joshfeck
joshfeck / myvoucher.php
Last active December 23, 2015 20:49
fork of another gettext filter function.
function myvoucher_filter_gettext( $translated, $original, $domain ) {
// This is an array of original strings
// and what they should be replaced with
$strings = array(
'Enter Voucher code:' => 'Enter Groupon code:',
// Add some more strings here
);
// See if the current string is in the $strings array
@joshfeck
joshfeck / custom-twitter-button.php
Created September 28, 2013 01:26
A simple plugin that will let you customize the default text that gets placed into a tweet. Works with Event Espresso and its social buttons add-on.
<?php
/*
Plugin Name: Custom Twitter Button for Event Espresso
Plugin URI: http://github.com/
Description: This plugin will override the tweet button in Event Espresso
Version: 1.0
Author: Sarah
License: GPLv2
*/
@joshfeck
joshfeck / remove_paypal.php
Created September 30, 2013 19:24
This will make it so that the PayPal button does not display when registering for a specific event. In this example, the event ID is 74. You'll need to swap in your event ID that you don't want the PayPal button to appear for.
<?php
function htrappfae_remove_paypal_from_event($payment_data) {
extract( $payment_data );
if ( $event_id==74 ) { //check to see if this is the event with the ID of #74
remove_action( 'action_hook_espresso_display_offsite_payment_gateway', 'espresso_display_paypal' );
}
}
add_action ( 'action_hook_espresso_display_offsite_payment_gateway', 'htrappfae_remove_paypal_from_event', 9 );
@joshfeck
joshfeck / jwlocpt.php
Last active December 27, 2015 15:29
Add a waitlist event post link to an event custom post type. Requires Event Espresso 3.x. Add to single-espresso_event.php
<?php
// get the waitlist event data for this event
$cpt_event = $wpdb->get_row("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");
$event_attendees_max = $cpt_event->reg_limit;
$num_attendees = get_number_of_attendees_reg_limit($event_id, 'num_attendees'); //Get the number of attendees
$allow_overflow = $cpt_event->allow_overflow;
@joshfeck
joshfeck / custom_function.php
Created November 15, 2013 22:04
removes social buttons for one event
<?php
//* Do NOT include the opening php tag unless this is going into its own file
function my_remove_social_buttons($event_id){
if ($event_id == '5')
remove_action('action_hook_espresso_social_display_buttons', 'espresso_social_display_buttons', 10, 1);
}
add_action('action_hook_espresso_social_display_buttons', 'my_remove_social_buttons', 9, 1);
@joshfeck
joshfeck / ee3_email_custom_functions.php
Last active December 18, 2018 14:55
use wp_mail_content_type filter instead of hard coding the content type in the email function. Event Espresso 3.1.35
<?php
function event_espresso_send_email($params) {
global $org_options;
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
extract($params);
//Define email headers
$headers = "";
if ($org_options['email_fancy_headers']=='Y') {
$headers .= "From: " . $org_options['organization'] . " <" . $org_options['contact_email'] . ">\r\n";
@joshfeck
joshfeck / ngg_play_fair.php
Last active December 30, 2015 03:39
This function will disable the NextGen gallery plugin's output buffering that breaks the Espresso API JSON feed. Add this to your theme's functions.php file or your own custom functionality plugin.
<?php
// Please do NOT include the opening php tag
/* Wrangle NextGen Gallery so it doesn't break the json API */
add_action( 'init','ee_nextgen_play_fair',1 );
function ee_nextgen_play_fair(){
if( preg_match( "/espresso-api/", $_SERVER['REQUEST_URI'] ) ){
@joshfeck
joshfeck / espresso-custom-title-tag.php
Last active December 30, 2015 12:49
This is a little plugin that adds the event name to the page's <title> tag. Requires Event Espresso 3.1.35.P or higher.
<?php
/*
Plugin Name: Custom Espresso Title tags
Plugin URI: http://gist.github.com/
Description: Adds the event name to the page's <title> tag. Requires Event Espresso 3.1.35.P or higher.
Version: 1.0
Author: Josh Feck
License: GPLv2
*/