Skip to content

Instantly share code, notes, and snippets.

@joshfeck
joshfeck / attendee_list.php
Last active August 29, 2015 14:01
Displays an attendee list after the content on the event details page. Displays the gravatar, first name, and last name of each attendee registered for an event. Requires Event Espresso 4.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// prints a per event attendee list right after the event details on a single event page
// you can change the action hook that's on the next line to display the list in another location
add_action( 'AHEE_event_details_after_the_content', 'ee_attendee_list' );
function ee_attendee_list(){
global $wpdb, $post;
@joshfeck
joshfeck / ee_reg_page_title.php
Created May 15, 2014 15:15
Adds the event name to the meta page title tag. Requires Event Espresso 3. Outputs: "{Event Name} | {Site Name}"
<?php // remove this line if your functions file already has an opening PHP tag
/**
* Creates a nicely formatted and more specific title element text
* for output in head of document, based on current event.
*
*/
function ee_reg_page_title( $title, $sep ) {
@joshfeck
joshfeck / functions.php
Created May 20, 2014 19:08
Modifies the Event Espresso calendar query to include events that have not ended yet when show_expired=false is set
<?php // remove if there's already an opening PHP tag in your funcitons.php file
add_filter ( 'filter_hook_espresso_calendar_sef_and_start_end_dates', 'my_custom_calendar_query_not_yet_ended' );
function my_custom_calendar_query_not_yet_ended() {
// this will filter the query so events that have closed for registration, but haven't ended yet,
// will display when show_expired is false
$today = date( 'Y-m-d' );
$sql = " AND e.end_date >= '$today' ";
return $sql;
@joshfeck
joshfeck / is_custom_date_field.php
Created June 3, 2014 16:44
Example code for sending the event start date to infusionsoft as a custom date field.
<?php
function espresso_infusionsoft_save_date_field($attendee_data) {
$clean_attendee_data = array(
//Example of a custom contact data field
//NOTE: You must prepend custom field database names with an underscore when accessing them through the API
'_CustomDateField' => $attendee_data['start_date'],
);
@joshfeck
joshfeck / add-to-function.pdf.php
Created June 3, 2014 16:58
This method can be added to the Espresso_PDF class in gateways/invoice/function.pdf.php to prepare some data to display the prices without the surcharge, and the surcharge amount as line items. Works with the Event Espresso 3.1.35.P or greater invoice template. Please see https://gist.github.com/joshfeck/e2b91cd6599000ecb772 for example template…
function my_itemised_surcharge($registration_ids, $attendees){
$options = get_option('events_organization_settings');
$currency = $options['currency_symbol'];
$this->SetFillColor(192,192,192);
// pull the selected ticket price breakdown from the database
global $wpdb, $org_options;
foreach( $registration_ids as $registration_id ) {
$price_query = "SELECT event_id, price_option FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id=%s";
@joshfeck
joshfeck / add-to-template.php
Created June 3, 2014 17:00
This gist works in conjunction with https://gist.github.com/joshfeck/52ac749150322a2e4221. You can add the following to /gateways/invoice/template.php to display the price without surcharge and surcharge amount as line items on the invoice.
// suggested code placement is right after the line that says:
// $pdf->ImprovedTable($header, $attendees, $w, $alling);
$pdf->Ln(1);
$pdf->my_itemised_surcharge($registration_ids, $attendees);
@joshfeck
joshfeck / add-GST-to-invoice.php
Last active August 29, 2015 14:02
A simple GST line itemizer for the Event Espresso 3 invoice template function file. Works in conjunction with https://gist.github.com/joshfeck/e2b91cd6599000ecb772
<?php
//* Please do NOT include the above opening php tag
function my_itemised_surcharge( $attendees ){
$options = get_option( 'events_organization_settings' );
$currency = $options['currency_symbol'];
$this->SetFillColor( 239,239,239 );
// pull the selected ticket price breakdown from the database
global $org_options;
@joshfeck
joshfeck / list-of-events.php
Created June 24, 2014 16:03
This code can be placed within a page template to display a list of events. Requires Event Espresso 3.
<ul class="course-list">
<?php
if( function_exists( 'espresso_reg_url' )) {
global $wpdb;
$tablename = EVENTS_DETAIL_TABLE;
$courses = $wpdb->get_results("SELECT * FROM $tablename WHERE start_date >= '" . date('Y-m-d') . "' AND event_status <> 'D' ORDER BY start_date ");
foreach ( $courses as $course ){
echo '<li><a href="' . espresso_reg_url($course->id) . '">' . stripslashes($course->event_name) . '</a></li>';
}
}
@joshfeck
joshfeck / payment-settings-fixer.php
Created July 22, 2014 01:18
This can be installed as a plugin or if you have a site specific plugin already installed you can copy the add_action and the callback function to your plugin.
<?php
/**
* @package Payment Settings Fixer
* @version 0.1
*/
/*
Plugin Name: Payment Settings Fixer
Plugin URI: https://github.com/joshfeck
Description: A little patch to fix a strange issue in some WPEngine sites' admin for the Event Espresso 3 Payment settings page
Author: Josh Feck
@joshfeck
joshfeck / archive-espresso_events.php
Last active August 29, 2015 14:04
Example event archive loop that displays events in an html table. You can adapt this into your WP theme by copying its archive.php file into your child theme, rename it to archive-espresso_events.php. Then replace the standard loop with the following code example. Requires Event Espresso 4.
<?php if ( have_posts() ) : ?>
<table class="events">
<thead>
<tr>
<th>Event</th>
<th>Tickets available</th>
<th>Starts</th>
<tr>
</thead>