Support

Home Forums Event Espresso Premium email tag "location" and "google_map_link"

email tag "location" and "google_map_link"

Posted: September 16, 2015 at 3:37 am

Viewing 9 reply threads


sergio Pannella

September 16, 2015 at 3:37 am

after last update our confirmation email not display tags “location” and “google_map_link”

email manager:
***Diese Nachricht wurde automatisch erstellt – Bitte antworten Sie nicht auf diese Email***

Vielen Dank [fname] [lname] für Ihre Anmeldung zur Veranstaltung [event].

Beginn: [start_date] [start_time]

Ort: [location]
[google_map_link]

Wenn Sie Fragen haben, kontaktieren Sie bitte info@anne-kathrin.de oder telefonisch unter…

email:

***Diese Nachricht wurde automatisch erstellt – Bitte antworten Sie nicht auf diese Email***

Vielen Dank s p für Ihre Anmeldung zur Veranstaltung sergio test 050915.

Beginn: 05.10.2015

Ort: 17:00

Wenn Sie Fragen haben, kontaktieren Sie bitte….


Tony

  • Support Staff

September 16, 2015 at 4:14 am

Hi Sergio,

Is is just those 2 tags that do not display?

Do the shortcodes show as empty strings or do the show the shortcode within the email..

Like this “Ort: ” or like this “Ort: [location]”?

Have you clicked to re-save the confirmation email?


sergio Pannella

September 16, 2015 at 6:27 am

Yes just [location] and [google_map_link].
the email shows only name , start date and start time. “Ort:” as shown above, without shortcode


Tony

  • Support Staff

September 16, 2015 at 7:22 am

Do you use the venue manager with your events?

As in did you add your Venues through this section – http://take.ms/3QnVp

Or do you add the venue details within the event, like this – http://take.ms/tNnGB


sergio Pannella

September 16, 2015 at 7:25 am

with venue manager


Lorenzo Orlando Caum

  • Support Staff

September 16, 2015 at 11:48 am

Hi there Sergio,

Could you switch location to the following shortcode?

[venue_address]


Lorenzo


sergio Pannella

September 17, 2015 at 1:51 am

Hi Lorenzo, with [venue_address] works, but with [google_map_link] not.

email manager (test):
[venue_address]
[google_map_link]

email (result):
schulstr. 28
München
80634
Deutschland


Tony

  • Support Staff

September 17, 2015 at 2:06 am

That’s really strange as [venue_address] and [location] both parse to the same variable.

Have you modified the espresso_replace_shortcodes() function at all?

It’s a pluggable function so I’m wondering if you have some custom code overriding the original function, this can be within you themes functions.php file, a site specific function or within a custom_functions.php file within /wp-content/uploads/espresso/

How did you update Event Espresso?
Through the dashboard or manually via FTP?
Did you update to the latest version? (3.1.37.5)


sergio Pannella

September 17, 2015 at 2:39 am

Hi Tony here a copy of “custom_functions.php file”(from upload path) and “email.php” (from “event-espresso/includes/functions/”). update EE 3.1.37.4.P with ftp

///wp-content/uploads/espresso/:
<?php
/*
Function Name: Maximum Date Display
Author: Seth Shoultes
Contact: seth@smartwebutah.com
Website: http://shoultes.net
Description: This function is used in the Events Table Display template file to show events for a maximum number of days in the future
Usage Example: 
Requirements: Events Table Display template file
Notes: 
*/
function display_event_espresso_date_max($max_days="null"){
	global $wpdb;
	//$org_options = get_option('events_organization_settings');
	//$event_page_id =$org_options['event_page_id'];
	if ($max_days != "null"){
		if ($_REQUEST['show_date_max'] == '1'){
			foreach ($_REQUEST as $k=>$v) $$k=$v;
		}
		$max_days = $max_days;
		$sql  = "SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= start_date AND start_date >= '".date ( 'Y-m-d' )."' AND is_active = 'Y' ORDER BY date(start_date)";
		event_espresso_get_event_details($sql);//This function is called from the event_list.php file which should be located in your templates directory.

	}				
}

/*
Function Name: Event Status
Author: Seth Shoultes
Contact: seth@eventespresso.com
Website: https://eventespresso.com
Description: This function is used to display the status of an event.
Usage Example: Can be used to display custom status messages in your events.
Requirements: 
Notes: 
*/
if (!function_exists('espresso_event_status')) {
	function espresso_event_status($event_id){
		$event_status = event_espresso_get_is_active($event_id);
		
		//These messages can be uesd to display the status of the an event.
		switch ($event_status['status']){
			case 'EXPIRED':
				$event_status_text = __('This event is expired.','event_espresso');
			break;
			
			case 'ACTIVE':
				$event_status_text = __('This event is active.','event_espresso');
			break;
			
			case 'NOT_ACTIVE':
				$event_status_text = __('This event is not active.','event_espresso');
			break;
			
			case 'ONGOING':
				$event_status_text = __('This is an ongoing event.','event_espresso');
			break;
			
			case 'SECONDARY':
				$event_status_text = __('This is a secondary/waiting list event.','event_espresso');
			break;
			
		}
		return $event_status_text;
	}
}

/*
Function Name: Custom Event List Builder
Author: Seth Shoultes
Contact: seth@eventespresso.com
Website: https://eventespresso.com
Description: This function creates lists of events using custom templates.
Usage Example: Create a page or widget template to show events.
Requirements: Template files must be stored in your wp-content/uploads/espresso/templates directory
Notes: 
*/
if (!function_exists('espresso_list_builder')) {
	function espresso_list_builder($sql, $template_file, $before, $after){
		
		global $wpdb, $org_options;
		//echo 'This page is located in ' . get_option( 'upload_path' );
		$event_page_id = $org_options['event_page_id'];
		$currency_symbol = $org_options['currency_symbol'];
		$events = $wpdb->get_results($sql);
		$category_id = $wpdb->last_result[0]->id;
		$category_name = $wpdb->last_result[0]->category_name;
		$category_desc = html_entity_decode( wpautop($wpdb->last_result[0]->category_desc) );
		$display_desc = $wpdb->last_result[0]->display_desc;
		
		if ($display_desc == 'Y'){
			echo '<p id="events_category_name-'. $category_id . '" class="events_category_name">' . stripslashes_deep($category_name) . '</p>';
			echo wpautop($category_desc);				
		}
		
		foreach ($events as $event){
			$event_id = $event->id;
			$event_name = $event->event_name;
			$event_identifier = $event->event_identifier;
			$active = $event->is_active;
			$registration_start = $event->registration_start;
			$registration_end = $event->registration_end;
			$start_date = $event->start_date;
			$end_date = $event->end_date;
			$reg_limit = $event->reg_limit;
			$event_address = $event->address;
			$event_address2 = $event->address2;
			$event_city = $event->city;
			$event_state = $event->state;
			$event_zip = $event->zip;
			$event_country = $event->country;
			$member_only = $event->member_only;
			$externalURL = $event->externalURL;
			$recurrence_id = $event->recurrence_id;
			
			$allow_overflow = $event->allow_overflow;
			$overflow_event_id = $event->overflow_event_id;
			
			//Address formatting
			$location = ($event_address != '' ? $event_address :'') . ($event_address2 != '' ? '<br />' . $event_address2 :'') . ($event_city != '' ? '<br />' . $event_city :'') . ($event_state != '' ? ', ' . $event_state :'') . ($event_zip != '' ? '<br />' . $event_zip :'') . ($event_country != '' ? '<br />' . $event_country :'');
			
			//Google map link creation
			$google_map_link = espresso_google_map_link(array( 'address'=>$event_address, 'city'=>$event_city, 'state'=>$event_state, 'zip'=>$event_zip, 'country'=>$event_country, 'text'=> 'Map and Directions', 'type'=> 'text') );
			
			//These variables can be used with other the espresso_countdown, espresso_countup, and espresso_duration functions and/or any javascript based functions.
			$start_timestamp = espresso_event_time($event_id, 'start_timestamp', get_option('time_format'));
			$end_timestamp = espresso_event_time($event_id, 'end_timestamp', get_option('time_format'));
			
			//This can be used in place of the registration link if you are usign the external URL feature
			$registration_url = $externalURL != '' ? $externalURL : get_option('siteurl') . '/?page_id='.$event_page_id.'&regevent_action=register&event_id='. $event_id;
		
			if (!is_user_logged_in() && get_option('events_members_active') == 'true' && $member_only == 'Y') {
				//Display a message if the user is not logged in.
				 //_e('Member Only Event. Please ','event_espresso') . event_espresso_user_login_link() . '.';
			}else{
	//Serve up the event list
	//As of version 3.0.17 the event lsit details have been moved to event_list_display.php
				echo $before = $before == ''? '' : $before;
				include('templates/'. $template_file);
				echo $after = $after == ''? '' : $after;
			} 
		}
	//Check to see how many database queries were performed
	//echo '<p>Database Queries: ' . get_num_queries() .'</p>';
	}
}

//wp-content/plugins/event-espresso/includes/functions/:

<?php

if (!function_exists('espresso_replace_shortcodes')) {
	function espresso_replace_shortcodes($message, $data) {
		global $wpdb, $org_options;
		$payment_data = espresso_get_total_cost(array('attendee_session'=>$data->attendee->attendee_session));
		$event_cost = $payment_data['total_cost'];
		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
		$SearchValues = array(
			"[event_id]",
			"[event_identifier]",
			"[registration_id]",
			"[fname]",
			"[lname]",
			"[phone]",
			"[event]",
			"[event_name]",
			"[description]",
			"[event_link]",
			"[event_url]",
			"[virtual_url]",
			"[virtual_phone]",
			"[venue_title]",
			"[venue_url]",
			"[venue_image]",
			"[venue_phone]",
			"[venue_address]", //shows the venue address
			"[txn_id]",
			"[cost]",
			"[event_price]",
			"[ticket_qty]",
			"[ticket_type]",
			"[ticket_link]",
			"[certificate_link]",
			"[contact]",
			"[company]",
			"[co_add1]",
			"[co_add2]",
			"[co_city]",
			"[co_state]",
			"[co_zip]",
			"[payment_url]",
			
			"[start_date]",
			"[start_time]",
			"[end_date]",
			"[end_time]",
			"[location]",
			"[location_phone]",
			"[google_map_link]",
			"[attendee_event_list]", //Creates a table of the attendee and event information
			"[custom_questions]",
			"[qr_code]",
			"[seating_tag]",
			"[edit_attendee_link]",
			"[add_to_calendar]"
		);

		$ReplaceValues = array(
			$data->attendee->event_id,
			$data->event->event_identifier,
			$data->attendee->registration_id,
			$data->attendee->fname,
			$data->attendee->lname,
			$data->event->venue_phone,
			$data->event->event_name,
			$data->event->event_name,
			$data->event->event_desc,
			$data->event_link,
			$data->event_url,
			$data->event->virtual_url,
			$data->event->virtual_phone,
			//Venue information
			$data->event->venue_name,
			$data->event->venue_url,
			$data->event->venue_image,
			$data->event->venue_phone,
			$data->location, //For the "[venue_address]" shortcode shows the venue address
			//Payment details
			$data->attendee->txn_id,
			$org_options['currency_symbol'] . $event_cost,
			$org_options['currency_symbol'] . $event_cost,
			$data->attendee->quantity,
			$data->attendee->price_option,
			$data->ticket_link,
			empty($data->certificate_link) ? '' : $data->certificate_link,
			empty($data->event->alt_email) ? $org_options['contact_email'] : $data->event->alt_email,
			//Organization details
			$org_options['organization'],
			$org_options['organization_street1'],
			$org_options['organization_street2'],
			$org_options['organization_city'],
			$org_options['organization_state'],
			$org_options['organization_zip'],
			$data->payment_link,
			$data->invoice_link,
			event_date_display($data->attendee->start_date),
			event_date_display($data->attendee->event_time, get_option('time_format')),
			event_date_display($data->attendee->end_date),
			event_date_display($data->attendee->end_time, get_option('time_format')),
			$data->location,
			$data->event->venue_phone,
			$data->google_map_link,
			$data->table_open . $data->table_heading . $data->event_table . $data->table_close,
			isset($data->email_questions) && !empty($data->email_questions) ? $data->email_questions : '',
			$data->qr_code,
			$data->seatingchart_tag,
			$data->edit_attendee,
			//Add to calendar link
			apply_filters('filter_hook_espresso_display_ical', array(
					'event_id' => $data->attendee->event_id,
					'registration_id' => $data->attendee->registration_id,
					'event_name' => $data->event->event_name,
					'event_desc' => wp_kses($data->event->event_desc,array()),
					'contact_email' => empty($data->event->alt_email) ? $org_options['contact_email'] : $data->event->alt_email,
					'start_time' => empty($event->start_time) ? '' : $event->start_time,
					'start_date' => event_date_display($data->attendee->start_date, get_option('date_format')),
					'end_date' => event_date_display($data->attendee->end_date, get_option('date_format')),
					'start_time' => empty($data->attendee->event_time) ? '' : $data->attendee->event_time,
					'end_time' => empty($data->attendee->end_time) ? '' : $data->attendee->end_time,
					'location' => $data->location,
				), '', '', TRUE
			)
		);
	
		//Get the questions and answers
		$questions = $wpdb->get_results("select qst.question as question, ans.answer as answer from " . EVENTS_ANSWER_TABLE . " ans inner join " . EVENTS_QUESTION_TABLE . " qst on ans.question_id = qst.id where ans.attendee_id = " . $data->attendee->id, ARRAY_A);
		//echo '<p>'.print_r($questions).'</p>';
		if ($wpdb->num_rows > 0 && $wpdb->last_result[0]->question != NULL) {
			foreach ($questions as $q) {
				$k = stripslashes( $q['question'] );
				$v = stripslashes( $q['answer'] );
	
				//Output the question
				array_push($SearchValues, "[" . 'question_' . $k . "]");
				array_push($ReplaceValues, $k);
	
				//Output the answer
				array_push($SearchValues, "[" . 'answer_' . $k . "]");
				array_push($ReplaceValues, rtrim($v, ",") );
			}
		}
		//Get the event meta
		//echo '<p>'.print_r($data->event->event_meta).'</p>';
		if (!empty($data->event->event_meta)) {
			foreach ($data->event->event_meta as $k => $v) {
				if (!empty($k) && !is_array($v)) {
					array_push($SearchValues, "[" . $k . "]");
					array_push($ReplaceValues, stripslashes_deep($v));
				}
			}
		}
		//Perform the replacement
		return str_replace($SearchValues, $ReplaceValues, $message);
	}
}

//Build the email
function espresso_prepare_email_data($attendee_id, $multi_reg, $custom_data='') {
	global $wpdb, $org_options;
	do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
	$data = new stdClass;
	$data->multi_reg = $multi_reg;
    $data->seatingchart_tag = '';
	//print_r($custom_data);
	//Create vars for the custom data
	if (!empty($custom_data)) { 
		extract($custom_data, EXTR_PREFIX_ALL, 'custom_data');
    } 
    
    //echo $custom_data_email_type;
	//Get the event record 
	if (empty($custom_data_email_type)) {
		$custom_data_email_type = '';
    }
    $data->email_type = $custom_data_email_type;
	$sql = "SELECT ed.* ";
	isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= ", v.name venue_name, v.address venue_address, v.address2 venue_address2, v.city venue_city, v.state venue_state, v.zip venue_zip, v.country venue_country, v.meta venue_meta " : '';
	$sql .= " FROM " . EVENTS_DETAIL_TABLE . " ed ";
	isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? $sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " r ON r.event_id = ed.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = r.venue_id " : '';
	$sql .= " JOIN " . EVENTS_ATTENDEE_TABLE . " ea ON ea.event_id=ed.id ";
	$sql .= " WHERE ea.id = '" . $attendee_id . "' ";
	$data->event = $wpdb->get_row($sql, OBJECT);
    
	//Get the attendee record
	$sql = "SELECT ea.* FROM " . EVENTS_ATTENDEE_TABLE . " ea WHERE ea.id = '" . $attendee_id . "' ";
	$data->attendee = $wpdb->get_row($sql, OBJECT);

	//Get the primary/first attendee
	$data->primary_attendee = espresso_is_primary_attendee($data->attendee->id) == true ? true : false;

	$data->event->event_meta = unserialize($data->event->event_meta);

	//Venue variables
	if (isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y') {
		$data->event->venue_meta = unserialize($data->event->venue_meta);

		//Debug
		//echo "<pre>".print_r($data->event->venue_meta,true)."</pre>";

		$data->event->venue_url = $data->event->venue_meta['website'];
		$data->event->venue_phone = $data->event->venue_meta['phone'];
		$data->event->venue_image = '<img />event->venue_meta['image'].'" />';
		$data->event->venue_name = $data->event->venue_name;
		$data->event->address = $data->event->venue_address;
		$data->event->address2 = $data->event->venue_address2;
		$data->event->city = $data->event->venue_city;
		$data->event->state = $data->event->venue_state;
		$data->event->zip = $data->event->venue_zip;
		$data->event->country = $data->event->venue_country;
	} else {
		$data->event->venue_name = $data->event->venue_title;
		
	}
	//Build the table to hold the event and attendee info
	$data->table_open = '<table width="100%" border="1" cellpadding = "5" cellspacing="5" style="border-collapse:collapse;">';
	$data->table_heading = "<tr><th>" . __('Event Name', 'event_espresso') . "</th><th>" . __('Date', 'event_espresso') . "</th><th>" . __('Time', 'event_espresso') . "</th><th>" . __('Location', 'event_espresso') . "</th></tr>";
	$data->table_close = "</table>";

	//Clear ticket data
	$data->qr_code = '';
	$data->ticket_link = '';
	$data->admin_ticket_link = '';
    
    if (defined("ESPRESSO_SEATING_CHART")) {
        if (class_exists("seating_chart")) {
            if ( seating_chart::check_event_has_seating_chart($data->event->id)) {
                $rs = $wpdb->get_row("select scs.* from ".EVENTS_SEATING_CHART_EVENT_SEAT_TABLE." sces inner join ".EVENTS_SEATING_CHART_SEAT_TABLE." scs on sces.seat_id = scs.id where sces.attendee_id = ".$attendee_id);
                if ( $rs !== NULL ) {
                    $data->seatingchart_tag = $rs->custom_tag." ".$rs->seat." ".$rs->row;
                }
            }
        }
    }
    
	//Old ticketing system
	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/template.php")) {
		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php")) {
			include_once(EVENT_ESPRESSO_UPLOAD_DIR . "/ticketing/functions.php");
			$data->qr_code = espresso_qr_code( array('attendee_id' => $data->attendee->id, 'registration_id' => $data->attendee->registration_id, 'event_code' => $data->event->event_code ));
		}
		$data->ticket_link = espresso_ticket_links($data->attendee->registration_id, $data->attendee->id);
		$data->admin_ticket_link = $data->ticket_link;
	}

	//New ticketing system version 2.0
	if (function_exists('espresso_ticket_launch')) {
		$data->qr_code = espresso_ticket_qr_code( array('attendee_id' => $data->attendee->id, 'registration_id' => $data->attendee->registration_id, 'event_code' => $data->event->event_code ));
		$data->ticket_link = espresso_ticket_links($data->attendee->registration_id, $data->attendee->id, TRUE);
		$data->admin_ticket_link = $data->ticket_link;
	}

	//certificate system
	if (function_exists('espresso_certificate_launch')) {
		$data->certificate_link = espresso_certificate_links($data->attendee->registration_id, $data->attendee->id);
		$data->admin_certificate_link = $data->certificate_link;
	}
        

	//Build the address
	$data->location = ($data->event->address != '' ? $data->event->address : '') . ($data->event->address2 != '' ? '<br />' . $data->event->address2 : '') . ($data->event->city != '' ? '<br />' . $data->event->city : '') . ($data->event->state != '' ? ', ' . $data->event->state : '') . ($data->event->zip != '' ? '<br />' . $data->event->zip : '') . ($data->event->country != '' ? '<br />' . $data->event->country : '');

	//Build Google map link
	$data->google_map_link = espresso_google_map_link(array('address' => $data->event->address, 'city' => $data->event->city, 'state' => $data->event->state, 'zip' => $data->event->zip, 'country' => $data->event->country));

	//Registration URL
	$data->event_url = espresso_reg_url($data->event->id);
	$data->event_link = '<a>event_url . '">' . stripslashes_deep($data->event->event_name) . '</a>';

	//Venue name
	if (!isset($data->event->venue_name))
		$data->event->venue_name = '';

	//Table of events registered for
	$data->event_table .= espresso_generate_attendee_event_list( $data );

	//Output custom questions
	if (function_exists('event_espresso_custom_questions_output')) {
		//Create the question display
		$email_questions_r = event_espresso_custom_questions_output(array('attendee_id' => $data->attendee->id, 'all_questions' => TRUE));
		if ($email_questions_r != '')
			$data->email_questions = '<tr><td colspan = "6">' . $email_questions_r . '</td></tr>';
		$data->event_table .= $data->email_questions;
	}

	<code>//Payment URL
	$payment_url = add_query_arg('r_id', $data->attendee->registration_id, get_permalink($org_options['return_url']));
	$data->payment_link = '<a href="' . $payment_url . '">' . __('View Your Payment Details','event_espresso') . '</a>';</code>

	// download link
	

	//Edit attendee link
	$data->edit_attendee = espresso_edit_attendee($data->attendee->registration_id, $data->attendee->id, $data->attendee->event_id, 'attendee', __('Edit Registration Details','event_espresso'));

	$data->email_subject = !$data->multi_reg ? $data->event->event_name : $org_options['organization'] . __(' registration confirmation', 'event_espresso');
    
	//Build invoice email
	if ($custom_data_email_type == 'invoice') {
		$data->email_subject = $custom_data_invoice_subject;
		$data->event->conf_mail = $custom_data_invoice_message;
		$data->event->send_mail = 'Y';
		$data->event->email_id = empty($_REQUEST['email_name']) ? '' : $_REQUEST['email_name'];
	}
    
	//Build payment email
	if ($custom_data_email_type == 'payment') { 
		$data->email_subject = $custom_data_payment_subject;
		$data->event->conf_mail = $custom_data_payment_message;
		$data->event->send_mail = 'Y'; 
        $data->event->email_id = 0;
	} 
	
	//Build reminder email
	if ($custom_data_email_type == 'reminder') {
		$data->email_subject = $custom_data_email_subject;
		$data->event->conf_mail = $custom_data_email_text;
		$data->event->send_mail = 'Y';
		$data->event->email_id = $custom_data_email_id > 0 ? $custom_data_email_id : '';
	}

	return $data;
}

function espresso_generate_attendee_event_list( $data ) {

	global $wpdb;
	
	$use_venue = isset($org_options['use_venue_manager']) && $org_options['use_venue_manager'] == 'Y' ? TRUE : FALSE;
	
 	$SQL = 'SELECT att.event_id, att.price_option, att.start_date, att.end_date, att.event_time, att.end_time, att.email, att.attendee_session, evt.id, evt.event_name ';	
 	$SQL .= $use_venue ? ', v.name venue_name ' : ', evt.venue_title venue_name ';
	$SQL .= 'FROM ' . EVENTS_ATTENDEE_TABLE . ' att ';
	$SQL .= 'LEFT JOIN ' . EVENTS_DETAIL_TABLE . ' evt ON evt.id=att.event_id ';	
	$SQL .= $use_venue ? " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " r ON r.event_id = evt.id LEFT JOIN " . EVENTS_VENUE_TABLE . " v ON v.id = r.venue_id " : '';	
	$SQL .= 'WHERE att.email = %s AND att.attendee_session = %s';
	$SQL .= 'ORDER BY att.start_date, att.event_time';

	$events = $wpdb->get_results( $wpdb->prepare( $SQL, $data->attendee->email, $data->attendee->attendee_session ));
	
	$table_row = '';
	foreach ( $events as $event ) {
		$table_row .= "
		<tr>
			<td>" . stripslashes_deep($event->event_name) . " | " . $event->price_option . "</td>
			<td>" . event_date_display($event->start_date) . ' - ' . event_date_display($event->end_date) . "</td>
			<td>" . event_date_display($event->event_time, get_option('time_format')) . " - " . event_date_display($event->end_time, get_option('time_format')) . "</td>
			<td>" . $event->venue_name . "<br />$data->location <br />$data->google_map_link</td>
		</tr>";	
	}

//	echo $wpdb->last_query;
//	echo $wpdb->print_error();
//	echo printr( $attendee, '$attendee' );
//	echo printr( $events, '$events' );
//	echo $table_row;
//	die();

	return $table_row;

}

//End espresso_prepare_email_data()
//Get the email ready to send
function espresso_prepare_email($data) {
	global $org_options;
	do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
	//Build the subject line
	$email_subject = $data->email_subject; 
	//Merge all the data
    
   
    if ($data->event->email_id > 0 && $data->event->send_mail == 'Y' ) { //Get the email template if it exists 
        $email_data = array();
        $email_data = espresso_email_message($data->event->email_id);
        $conf_mail = $email_data['email_text'];
        $email_subject = $email_data['email_subject'];
    } elseif ($data->event->conf_mail != '' && $data->event->send_mail == 'Y') {//Else get the custom event email 
        $conf_mail = $data->event->conf_mail;
    } else {//Else get the default email from the general settings 
        $conf_mail = $org_options['message'];
    }

	//Get the email subject
	$email_subject = espresso_replace_shortcodes($email_subject, $data);

	//Replace email shortcodes
	$_replaced = espresso_replace_shortcodes($conf_mail, $data);

	//Build the HTML
	$message_top = "<html><body>";
	$message_bottom = "</body></html>";
	$email_body = $message_top . $_replaced . $message_bottom;
	if (!isset($headers))
		$headers = '';
	return array(
			'send_to' => $data->attendee->email,
			'email_subject' => $email_subject,
			'email_body' => $email_body,
			'headers' => $headers
	);
}

//End espresso_prepare_email()
//Build the admin email
function espresso_prepare_admin_email($data) {
	global $org_options;
	do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
	//Edit attendee link
	$admin_attendee_link = espresso_edit_attendee($data->attendee->registration_id, $data->attendee->id, $data->attendee->event_id, 'admin', $data->attendee->fname . ' ' . $data->attendee->lname);

	//Group registration check
	$primary_attendee = $data->attendee->quantity > 0 && !$data->multi_reg && $data->primary_attendee == true ? "<p><strong>" . __('Primary Attendee', 'event_espresso') . "</strong></p>" : '';

	//Build the email title
	$admin_message = "<h3>" . __('Registration Summary:', 'event_espresso') . "</h3>";

	//Email body
	$attendee_quantity_count = $data->attendee->quantity;
	$admin_email_body = "<tr>
		<td>$primary_attendee $admin_attendee_link</td>
		<td>" . $data->attendee->email . "</td>
		<td>" . stripslashes_deep($data->event->event_name) . " | " . $data->attendee->price_option . "</td>
		<td>" . event_date_display($data->attendee->start_date) . ' - ' . event_date_display($data->attendee->end_date) . "</td>
		<td>" . event_date_display($data->attendee->event_time, get_option('time_format')) . " - " . event_date_display($data->attendee->end_time, get_option('time_format')) . "</td> " .
					($attendee_quantity_count > 0 ? '<td>' . $attendee_quantity_count . ' ' . sprintf( _n('attendee', 'attendees', $attendee_quantity_count, 'event_espresso') ) . '</td>' : '') . "</tr>";

	//Additional information/questions
	$admin_additional_info = "<h3>" . __('Additional Information:', 'event_espresso') . "</h3>";

	//Registration ID
	if (!empty($data->attendee->registration_id)) {
		$admin_additional_info .= '<strong>' . __('Registration ID: ', 'event_espresso') . '</strong><br />';
		$admin_additional_info .= $data->attendee->registration_id;
	}

	if (!empty($data->email_questions)) {
		$admin_additional_info .= $data->email_questions;
	}

	//Ticket links
	if (!empty($data->admin_ticket_link)) {
		$admin_additional_info .= '<strong>' . __('Ticket(s):', 'event_espresso') . '</strong><br />';
		$admin_additional_info .= $data->admin_ticket_link;
	}

	//Certificate links
	if (!empty($data->admin_certificate_link)) {
		$admin_additional_info .= '<strong>' . __('Certificate(s):', 'event_espresso') . '</strong><br />';
		$admin_additional_info .= $data->admin_certificate_link;
	}

	//invoice links
	if (!empty($data->invoice_link)) {
		$admin_additional_info .= '<p><strong>' . __('Invoice:', 'event_espresso') . '</strong><br />';
		$admin_additional_info .= $data->invoice_link;
		$admin_additional_info .= '</p>';
	}

	//Build the headers
	$headers = '';
	return array(
			'send_to' => $data->event->alt_email == '' ? $org_options['contact_email'] : $data->event->alt_email . ',' . $org_options['contact_email'],
			'email_subject' => !$data->multi_reg ? $data->event->event_name . ' ' . __('registration confirmation', 'event_espresso') : __('Event Registration Notification', 'event_espresso'),
			'email_body' => $admin_message . $data->table_open . $admin_email_body . $data->table_close . $admin_additional_info,
			'headers' => $headers
	);
}

//End espresso_prepare_admin_email()
function email_by_attendee_id($attendee_id, $send_attendee_email = TRUE, $send_admin_email = TRUE, $multi_reg = FALSE, $custom_data='') {
    
	$data = espresso_prepare_email_data($attendee_id, $multi_reg, $custom_data);
   
	
	if ($send_attendee_email == 'true') {
		$email_params = espresso_prepare_email($data);  
		event_espresso_send_email($email_params);
	}
	if ($send_admin_email == 'true') {
		$email_params = espresso_prepare_admin_email($data);
		event_espresso_send_email($email_params);
	}
}

//End email_by_attendee_id()
function 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);
	}
}//End 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 )) { 
		
			email_by_session_id($session_id, $send_attendee_email, $send_admin_email, $multi_reg);
			
		}
	}

}//End event_espresso_email_confirmations()

//Email sender
if (!function_exists('event_espresso_send_email')) {

	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";
			$headers .= "Reply-To: " . $org_options['organization'] . "  <" . $org_options['contact_email'] . ">\r\n";
		} else {
			$headers .= "From: " . $org_options['contact_email'] . "\r\n";
			$headers .= "Reply-To: " . $org_options['contact_email'] . "\r\n";
		}
		$headers .= "Content-Type: text/html; charset=utf-8\r\n";
		//Debug
//		 echo '<br/><br/><br/><br/>';
//		  echo '<p>$headers = '.$headers.'</p>';
//		  echo '<p>$send_to = '.$send_to.'</p>';
//		  echo '<p>$email_subject = '.$email_subject.'</p>';
//		  echo '<p>$email_body = '.$email_body.'</p>';
//		  echo '<p>'.$email_body.'</p>';
//		 echo '<br/><br/><br/><br/>';

		return wp_mail($send_to, stripslashes_deep(html_entity_decode($email_subject, ENT_QUOTES, "UTF-8")), stripslashes_deep(html_entity_decode(wpautop($email_body), ENT_QUOTES, "UTF-8")), $headers);
	}

}//End event_espresso_send_email()

//Send Invoice
if (!function_exists('event_espresso_send_invoice')) {

	function event_espresso_send_invoice( $registration_id, $invoice_subject, $invoice_message, $array_of_reg_ids = FALSE ) {
		global $wpdb, $org_options;
		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');

		$SQL ='SELECT a.id FROM '. EVENTS_ATTENDEE_TABLE . ' a	WHERE a.registration_id = %s';
		$result = $wpdb->get_row( $wpdb->prepare( $SQL, $registration_id ));

		$registration_id = isset($result->registration_id) && !empty($result->registration_id) ? $result->registration_id : '';
		$attendee_id = $result->id;

		event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'invoice', 'invoice_subject' => $invoice_subject, 'invoice_message' => $invoice_message)));

		return;
	}

}//End event_espresso_send_invoice()

//Payment Confirmations
if (!function_exists('event_espresso_send_payment_notification')) {

	function event_espresso_send_payment_notification($atts) {

		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');

		global $wpdb, $org_options;
		//Extract the attendee_id and registration_id
		extract($atts);
		
		$registration_id = is_array( $registration_id ) ? $registration_id[0] : $registration_id;
		
		if ( empty( $registration_id ) && isset( $attendee_id )) {
			$registration_id = espresso_registration_id($attendee_id);
		}
			
		if ( empty( $registration_id )) {
			return __('No Registration ID was supplied', 'event_espresso');
		}			

		//Get the attendee  id or registration_id and create the sql statement
		$SQL = "SELECT a.* FROM " . EVENTS_ATTENDEE_TABLE . " a ";
		$SQL .= " WHERE a.registration_id = %s ";
		$attendees = $wpdb->get_results( $wpdb->prepare( $SQL, $registration_id ));

		if ($org_options['default_mail'] == 'Y') { 
			foreach ($attendees as $attendee) {
				event_espresso_email_confirmations(array('attendee_id' => $attendee->id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'payment', 'payment_subject' => $org_options['payment_subject'], 'payment_message' => $org_options['payment_message'])));
			}
		}

		return;
	}

}

//Reminder Notices
if (!function_exists('espresso_event_reminder')) {

	function espresso_event_reminder($event_id, $email_subject='', $email_text='', $email_id=0) {
		global $wpdb, $org_options;
		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
		$count = 0;
		$SQL = 'SELECT * FROM ' . EVENTS_ATTENDEE_TABLE . ' WHERE event_id =%d GROUP BY lname, fname';
		
		$attendees = $wpdb->get_results( $wpdb->prepare( $SQL, $event_id ));
		
		if ($wpdb->num_rows > 0) {
			foreach ($attendees as $attendee) {
				$attendee_id = $attendee->id;
				event_espresso_email_confirmations(array('attendee_id' => $attendee_id, 'send_admin_email' => 'false', 'send_attendee_email' => 'true', 'custom_data' => array('email_type' => 'reminder', 'email_subject' => $email_subject, 'email_text' => $email_text, 'email_id' => $email_id)));
				$count++;
			}
			?>
			<div id="message" class="updated fade">
				<p><strong>
						<?php echo printf( _n('Email Sent to %d person successfully.', 'Email Sent to %d people successfully.', $count, 'event_espresso'), $count ); ?>
					</strong></p>
			</div>
			<?php
			return;
		} else {
			?>
			<div id="message" class="error fade">
				<p><strong>
						<?php _e('No attendee records available.', 'event_espresso'); ?>
					</strong></p>
			</div>
			<?php
		}
	}

}

//Cancelation Notices
if (!function_exists('event_espresso_send_cancellation_notice')) {

	function event_espresso_send_cancellation_notice($event_id) {
		global $wpdb, $org_options;
		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
		//Define email headers
		$headers = "";
		if ($org_options['email_fancy_headers']=='Y') {
			$headers .= "From: " . $org_options['organization'] . " <" . $org_options['contact_email'] . ">\r\n";
			$headers .= "Reply-To: " . $org_options['organization'] . "  <" . $org_options['contact_email'] . ">\r\n";
		} else {
			$headers .= "From: " . $org_options['contact_email'] . "\r\n";
			$headers .= "Reply-To: " . $org_options['contact_email'] . "\r\n";
		}
		$headers .= "Content-Type: text/html; charset=utf-8\r\n";
		$message_top = "<html><body>";
		$message_bottom = "</html></body>";

		$events = $wpdb->get_results("SELECT * FROM " . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'");
		foreach ($events as $event) {
			$event_name = $event->event_name;
			$event_desc = $event->event_desc;
			$send_mail = $event->send_mail;
			$conf_mail = $event->conf_mail;
			$email_id = $event->email_id;
			$alt_email = $event->alt_email;
			$start_date = $event->start_date;
			$end_date = $event->end_date;
			$event_address = $event->address;
			$event_address2 = $event->address2;
			$event_city = $event->city;
			$event_state = $event->state;
			$event_zip = $event->zip;
			$location = (!empty($event_address) ? $event_address : '') . (!empty($event_address2) ? '<br />' . $event_address2 : '') . (!empty($event_city) ? '<br />' . $event_city : '') . (!empty($event_state) ? ', ' . $event_state : '') . (!empty($event_zip) ? '<br />' . $event_zip : '') . (!empty($event_country) ? '<br />' . $event_country : '');
			$location_phone = $event->phone;

			$attendees = $wpdb->get_results("SELECT * FROM " . EVENTS_ATTENDEE_TABLE . " WHERE event_id ='" . $event_id . "'");
			foreach ($attendees as $attendee) {
				$lname = $attendee->lname;
				$fname = $attendee->fname;
				$address = $attendee->address;
				$city = $attendee->city;
				$state = $attendee->state;
				$zip = $attendee->zip;
				$attendee_email = $attendee->email;
				$phone = $attendee->phone;
				$date = $attendee->date;
				$event_id = $attendee->event_id;
				$event_time = $attendee->event_time;
				$end_time = $attendee->end_time;

				//Replace the tags
				//$tags = array("[fname]", "[lname]", "[event_name]" );
				//$vals = array($fname, $lname, $event_name);
				//$email_body = $message_top.$email_body.$message_bottom;
				//$subject = str_replace($tags,$vals,$email_subject);

				$subject = __('Event Cancellation Notice', 'event_espresso');
				$email_body = '<p>' . sprintf( __( '%d has been cancelled.', 'event_espresso' ), $event_name ) . '</p>';
				$email_body .= '<p>' . sprintf( __('For more information, please email %d', 'event_espresso'), $alt_email == '' ? $org_options['contact_email'] : $alt_email ) . '</p>';
				$body = str_replace($tags, $vals, $email_body);
				wp_mail($attendee_email, stripslashes_deep(html_entity_decode($subject, ENT_QUOTES, "UTF-8")), stripslashes_deep(html_entity_decode(wpautop($email_body), ENT_QUOTES, "UTF-8")), $headers);
			}
		}
	}

}

// Attendee registration approval pending
if (!function_exists('event_espresso_send_attendee_registration_approval_pending')) {

	function event_espresso_send_attendee_registration_approval_pending($registration_id) {
		global $org_options, $wpdb;
		do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, '');
		//Get the event information
		$events = $wpdb->get_results("SELECT ed.* FROM " . EVENTS_DETAIL_TABLE . " ed
						JOIN " . EVENTS_ATTENDEE_TABLE . " ea
						ON ed.id = ea.event_id
						WHERE ea.registration_id='" . $registration_id . "'");

		foreach ($events as $event) {
			$event_id = $event->id;
			$event_name = stripslashes_deep($event->event_name);
			$event_desc = stripslashes_deep($event->event_desc);
			$display_desc = $event->display_desc;
			$event_identifier = $event->event_identifier;
			$reg_limit = $event->reg_limit;
			$active = $event->is_active;
			$send_mail = $event->send_mail;
			$conf_mail = $event->conf_mail;
			$email_id = $event->email_id;
			$alt_email = $event->alt_email;
			$start_date = event_date_display($event->start_date);
			$end_date = $event->end_date;
			$virtual_url = $event->virtual_url;
			$virtual_phone = $event->virtual_phone;
			$event_address = $event->address;
			$event_address2 = $event->address2;
			$event_city = $event->city;
			$event_state = $event->state;
			$event_zip = $event->zip;
			$event_country = $event->country;
			$location = ($event_address != '' ? $event_address : '') . ($event_address2 != '' ? '<br />' . $event_address2 : '') . ($event_city != '' ? '<br />' . $event_city : '') . ($event_state != '' ? ', ' . $event_state : '') . ($event_zip != '' ? '<br />' . $event_zip : '') . ($event_country != '' ? '<br />' . $event_country : '');
			$location_phone = $event->phone;
			$require_pre_approval = $event->require_pre_approval;

			$google_map_link = espresso_google_map_link(array('address' => $event_address, 'city' => $event_city, 'state' => $event_state, 'zip' => $event_zip, 'country' => $event_country));
		}

		//Build links
		$event_url = espresso_reg_url($event_id);
		$event_link = '<a href="' . $event_url . '">' . $event_name . '</a>';

		$sql = "SELECT * FROM " . EVENTS_ATTENDEE_TABLE;

		if ($registration_id != '') {
			$sql .= " WHERE registration_id = '" . $registration_id . "' ";
		} elseif ($attendee_id != '') {
			$sql .= " WHERE id = '" . $attendee_id . "' ";
		} else {
			_e('No ID Supplied', 'event_espresso');
		}

		$sql .= " ORDER BY id ";
		$sql .= " LIMIT 0,1 "; //Get the first attendees details

		$attendees = $wpdb->get_results($sql);
		//global $attendee_id;

		foreach ($attendees as $attendee) {
			$attendee_id = $attendee->id;
			$attendee_email = $attendee->email;
			$lname = $attendee->lname;
			$fname = $attendee->fname;
			$address = $attendee->address;
			$address2 = $attendee->address2;
			$city = $attendee->city;
			$state = $attendee->state;
			$zip = $attendee->zip;
			$payment_status = $attendee->payment_status;
			$txn_type = $attendee->txn_type;
			$amount_pd = $attendee->amount_pd;
			$event_cost = $attendee->amount_pd;
			$payment_date = event_date_display($attendee->payment_date);
			$phone = $attendee->phone;
			$event_time = event_date_display($attendee->event_time, get_option('time_format'));
			$end_time = event_date_display($attendee->end_time, get_option('time_format'));
			$date = event_date_display($attendee->date);
			$pre_approve = $attendee->pre_approve;
		}
		$admin_email = $alt_email == '' ? $org_options['contact_email'] : $alt_email . ',' . $org_options['contact_email'];
		if (!empty($admin_email)) {
			$subject = __('New attendee registration approval pending','event_espresso');
			$body = sprintf( __('Event title: %s', 'event_espresso'), $event_name );
			$body .= '<br/>';
			$body .= sprintf( __('Attendee name: %1$s %2$s', 'event_espresso'), $fname, $lname );
			$body .= '<br/>';
			$body .= __('Thank You.', 'event_espresso');
			$email_params = array(
					'send_to' => $admin_email,
					'email_subject' => __($subject, 'event_espresso'),
					'email_body' => $body
			);
			event_espresso_send_email($email_params);
		}

		if (!empty($attendee_email)) {
			$subject = __('Event registration pending','event_espresso');
			$body = sprintf( __('Event title: %s', 'event_espresso'), $event_name );
			$body .= '<br/>';
			$body .= sprintf( __('Attendee name: %1$s %2$s', 'event_espresso'), $fname, $lname );
			$body .= '<br/>';
			$body .= __('Your registration is pending for approval from event admin. You will receive an email with payment info when admin approves your registration.', 'event_espresso');
			$body .= '<br/><br/>';
			$body .= __('Thank You.', 'event_espresso');
			$email_params = array(
					'send_to' => $attendee_email,
					'email_subject' => __($subject, 'event_espresso'),
					'email_body' => $body
			);
			event_espresso_send_email($email_params);
		}
	}

}

/**
 * 		@ print_r an array
 * 		@ access public
 * 		@ return void
 */
function printr($var, $var_name = 'ARRAY', $height = 'auto') {

	echo '<pre style="display:block; width:100%; height:' . $height . '; overflow:scroll; border:2px solid light-blue;">';
	echo '<h3>' . $var_name . '</h3>';
	echo print_r($var);
	echo '</pre>';
}


Tony

  • Support Staff

September 18, 2015 at 4:52 am

I’ve been trying to recreate this but so far have been unable to.

Can you try re-installing the latest version of EE3 through the Plugin manager rather than FTP please?

Create a full site backup just to be safe.

De-activate and delete the current version of EE3 that you have installed (or rename the EE plugin directory to ‘event-espresso-temp’)

Download the latest version of EE3 from your account page.

Then go to Dashboard -> Plugins -> Add New -> Upload. Select the zip file you just downloaded, activate and retest.

Viewing 9 reply threads

The support post ‘email tag "location" and "google_map_link"’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso