The code in this gist has been deprecated in favor of the EE4 Ticketing Add-on automatically adding a Ticket Link to ESPRESSO_MY_EVENTS.
Please update to the latest version of both the EE4 User Intergration add-on and EE4 Ticketing add-on
The code in this gist has been deprecated in favor of the EE4 Ticketing Add-on automatically adding a Ticket Link to ESPRESSO_MY_EVENTS.
Please update to the latest version of both the EE4 User Intergration add-on and EE4 Ticketing add-on
<?php | |
/* | |
Plugin Name: Event Espresso site specific functions | |
Description: Add custom functions for Event Espresso to this plugin. | |
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
/* | |
function tw_add_ticket_link_to_my_events( $actions, $registration) { | |
if ( $registration instanceof EE_Registration ) { | |
if ( EEH_MSG_Template::is_mt_active( 'ticketing' ) && $registration->is_approved() ) { | |
//we need to get the correct template ID for the given event | |
$event = $registration->event(); | |
//get the assigned ticket template for this event | |
$mtp = EEM_Message_Template_Group::instance()->get_one( array( array( 'Event.EVT_ID' => $event->ID(), 'MTP_message_type' => 'ticketing' ) ) ); | |
//if no $mtp then that means an existing event that hasn't been saved yet with the templates for the global ticketing template. So let's just grab the global. | |
$mtp = $mtp instanceof EE_Message_Template_Group ? $mtp : EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_is_global' => 1, 'MTP_message_type' => 'ticketing' ) ) ); | |
$query_args = array( | |
'ee' => 'msg_url_trigger', | |
'snd_msgr' => 'html', | |
'gen_msgr' => 'html', | |
'message_type' => 'ticketing', | |
'context' => 'registrant', | |
'token' => $registration->reg_url_link(), | |
'GRP_ID' => $mtp->ID(), | |
'id' => 0 | |
); | |
$ticket_url = add_query_arg( $query_args, get_site_url() ); | |
$actions['ticket'] = '<a aria-label="' . __( 'Link to view ticket', 'event_espresso' ) . '" href="' . $ticket_url . '">' | |
. '<span class="dashicons dashicons-tickets-alt ee-icon-size-18"></span></a>'; | |
} | |
} | |
return $actions; | |
} | |
add_filter( 'FHEE__EES_Espresso_My_Events__actions', 'tw_add_ticket_link_to_my_events', 10, 2); | |
function tw_add_ticket_link_to_my_events_legend( $items ) { | |
$items['ticket'] = array( | |
'class' => 'dashicons dashicons-tickets-alt', | |
'desc' => esc_html__( 'View Ticket', 'event_espresso' ) | |
); | |
return $items; | |
} | |
add_filter( 'FHEE__status-legend-espresso_my_events__legend_items', 'tw_add_ticket_link_to_my_events_legend'); | |
*/ |