Created
July 26, 2013 20:41
-
-
Save joshfeck/6092061 to your computer and use it in GitHub Desktop.
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
//event_espresso_send_email($attendee_email_params); | |
} | |
if ($send_admin_email == 'true') { | |
$email_params = espresso_prepare_admin_email($data); | |
$admin_email_params['send_to'] = $email_params['send_to']; | |
$admin_email_params['email_subject'] = $email_params['email_subject']; | |
$admin_email_params['email_body'] .= '<----------------------------------------------><br />'; | |
$admin_email_params['email_body'] .= $email_params['email_subject'] . '<br />'; | |
$admin_email_params['email_body'] .= '<----------------------------------------------><br />'; | |
$admin_email_params['email_body'] .= $email_params['email_body'] . '<br />'; | |
$admin_email_params['headers'] = $email_params['headers']; | |
} | |
} | |
if ($send_admin_email == 'true') { | |
event_espresso_send_email($admin_email_params); | |
} | |
if ($send_attendee_email == 'true') { | |
event_espresso_send_email($attendee_email_params); | |
} | |
} | |
//End msec_email_by_session_id() | |
if ( ! function_exists('event_espresso_email_confirmations')) { | |
function event_espresso_email_confirmations($atts) { | |
extract($atts); | |
//print_r($atts); | |
$multi_reg = empty( $multi_reg ) ? FALSE : $multi_reg; | |
$send_admin_email = empty( $send_admin_email ) ? FALSE : $send_admin_email; | |
$send_attendee_email = empty( $send_attendee_email ) ? FALSE : $send_attendee_email; | |
$custom_data = empty( $custom_data ) ? '' : $custom_data; | |
if ( ! empty( $attendee_id ) && ! $multi_reg ) { | |
email_by_attendee_id($attendee_id, $send_attendee_email, $send_admin_email, $multi_reg, $custom_data); | |
} elseif ( ! empty( $registration_id ) && ! $multi_reg ) { | |
global $wpdb; | |
$sql = "SELECT id FROM " . EVENTS_ATTENDEE_TABLE . " WHERE registration_id = %s"; | |
$attendees = $wpdb->get_col( $wpdb->prepare( $sql, $registration_id )); | |
foreach ($attendees as $attendee_id) { | |
email_by_attendee_id($attendee_id, $send_attendee_email, $send_admin_email, $multi_reg, $custom_data); | |
} | |
} elseif ( ! empty( $session_id )) { | |
msec_email_by_session_id($session_id, $send_attendee_email, $send_admin_email, $multi_reg); | |
} | |
} | |
}//End event_espresso_email_confirmations() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment