Show ticketname(s) for logged in user on grid page
-
On the event grid page I am using the conditional placeholder
is_user_attendee
to show a text like “Your reservation is confirmed”. That works fine. Now I would also show the name of the ticket(s) this user has ordered. I made a custom placeholder like this:add_filter('em_event_output_placeholder','my_em_ticket_string',1,3);
function my_em_ticket_string($replace, $EM_Event, $result){
? ? if( $result == '#_TICKETSTRING' ){
? ? ? ? $replace = '';
? ? ? ? $EM_Bookings = $EM_Event->get_bookings();
? ? ? ? if( count($EM_Bookings->bookings) > 0 ){
? ? ? ? ? ? foreach( $EM_Bookings as $EM_Booking){
? ? ? ? ? ? ? ? $ticket_name = "";
? ? ? ? ? ? ? ? ? ? foreach ( $EM_Booking->get_tickets() as $EM_Ticket ) {
? ? ? ? ? ? ? ? ? ? ? ? if ($ticket_name == "") {
? ? ? ? ? ? ? ? ? ? ? ? ? ? $ticket_name = $EM_Ticket->name;
? ? ? ? ? ? ? ? ? ? ? ? } else {
? ? ? ? ? ? ? ? ? ? ? ? ? ? $ticket_name = $ticket_name . ', ' . $EM_Ticket->name;
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? $replace = $ticket_name;
? ? }
? ? return $replace;
}Unfortunate this is working good. Yes is shows ticket name(s), but not always from the logged in user. Instead it shows the ticket name of the first user who ordered a ticket. So my code is somehow missing a check for the logged in user. How can I improve this?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.