Display attendees at frontend?

Home Forums Ticket Products Event Tickets Plus Display attendees at frontend?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #992011
    Julladaj
    Participant

    How can I display attendees at frontend?
    Any solution for that please guide me, thanks.

    #992018
    Julladaj
    Participant

    Problem is solve now after I try solution from this
    https://theeventscalendar.com/support/forums/topic/displaying-attendee-list-on-front-end-single-event/

    Now my Single_Event.php become like this

    <?php
    /**
     * @for     Single Event Template
     * This file contains the hook logic required to create an effective single event view.
     *
     * @package TribeEventsCalendar
     *
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( '-1' );
    }
    
    if ( ! class_exists( 'Tribe__Events__Template__Single_Event' ) ) {
    	/**
    	 * Single event template class
    	 */
    	class Tribe__Events__Template__Single_Event extends Tribe__Events__Template_Factory {
    
    		protected $body_class = 'events-single';
    
    		public function hooks() {
    			parent::hooks();
    
    			// google data markup
    			add_action( 'wp_head', array( $this, 'google_data_markup' ) );
    
    		}
    
    		public function google_data_markup() {
    			$html = apply_filters( 'tribe_google_data_markup_json', Tribe__Events__Google_Data_Markup::instance()->script_block() );
    			echo $html;
    		}
    
    		/**
    		 * Setup meta display in this template
    		 *
    		 * @return void
    		 **/
    		public function setup_meta() {
    
    			parent::setup_meta();
    
    			/**
    			 * Setup default meta templates
    			 * @var array
    			 */
    			$meta_template_keys = apply_filters(
    				'tribe_events_single_event_meta_template_keys', array(
    					'tribe_event_date',
    					'tribe_event_cost',
    					'tribe_event_category',
    					'tribe_event_tag',
    					'tribe_event_website',
    					'tribe_event_origin',
    					'tribe_event_venue_name',
    					'tribe_event_venue_phone',
    					'tribe_event_venue_address',
    					'tribe_event_venue_website',
    					'tribe_event_organizer_name',
    					'tribe_event_organizer_phone',
    					'tribe_event_organizer_email',
    					'tribe_event_organizer_website',
    					'tribe_event_custom_meta'
    				)
    			);
    			$meta_templates     = apply_filters(
    				'tribe_events_single_event_meta_templates', array(
    					'before'       => '',
    					'after'        => '',
    					'label_before' => '<dt>',
    					'label_after'  => '</dt>',
    					'meta_before'  => '<dd class="%s">',
    					'meta_after'   => '</dd>'
    				)
    			);
    			tribe_set_the_meta_template( $meta_template_keys, $meta_templates );
    
    			/**
    			 * Setup default meta group templates
    			 * @var array
    			 */
    			$meta_group_template_keys = apply_filters(
    				'tribe_events_single_event_meta_group_template_keys', array(
    					'tribe_event_details',
    					'tribe_event_venue',
    					'tribe_event_organizer'
    				)
    			);
    			$meta_group_templates     = apply_filters(
    				'tribe_events_single_event_meta_group_templates', array(
    					'before'       => '<div class="%s">',
    					'after'        => '</div>',
    					'label_before' => '<h3 class="%s">',
    					'label_after'  => '</h3>',
    					'meta_before'  => '<dl>',
    					'meta_after'   => '</dl>'
    				)
    			);
    
    			tribe_set_the_meta_template( $meta_group_template_keys, $meta_group_templates, 'meta_group' );
    		}
    
    		/**
    		 * Set up the notices for this template
    		 *
    		 * @return void
    		 **/
    		public function set_notices() {
    			parent::set_notices();
    			$events_label_singular = tribe_get_event_label_singular();
    
    			global $post;
    
    			// Check if event has passed
    			$gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : " " . get_option( 'gmt_offset' );
    			$gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );
    
    			if ( ! tribe_is_showing_all() && strtotime( tribe_get_end_date( $post, false, 'Y-m-d G:i' ) . $gmt_offset ) <= time() ) {
    				Tribe__Events__Main::setNotice( 'event-past', sprintf( __( '[:en]This %s has finished.[:th]กิจกรรมนี้ได้ปิดการสำรองที่นั่งแล้ว', 'tribe-events-calendar' ), strtolower( $events_label_singular ) ) );
    			}
    			
    			// Build a list of attendees
    			$event_id = get_the_ID();
    			$attendeeList = TribeEventsTickets::get_event_attendees($event_id);
    			$customerList = array();
    			$frontend_attendees = '<h2 class="tribe-events-single-event-title summary entry-title">'.__('[:en]Attendees list[:th]รายชื่อผู้ลงทะเบียน').'</h2><p>'.__('[:en]After reserve event, please wait staff to approve your order.[:th]หลังจากทำการสำรองที่นั่ง กรุณารอเจ้าหน้าที่ทำการตรวจสอบเพื่อให้การสำรองที่นั่งเสร็จสมบูรณ์.').'</p>';
    
    			// Build a list of customers (by order ID)
    			if (is_array($attendeeList)) {
    				foreach ($attendeeList as $attendeeData) {
    					// Record the order ID and number of attendees per order
    					if (!isset($customerList[$attendeeData['order_id']])) {
    					$customerList[$attendeeData['order_id']] = 1;
    					} else {
    					$customerList[$attendeeData['order_id']]++;
    					}
    				}
    			}
    
    			if (count($customerList) > 0) {
    				$frontend_attendees .= '
    				<div class="woocommerce" id="attendee-list">
    				<table class="shop_table shop_table_responsive my_account_orders">
    				<thead>
    				<tr>
    				<th class="order-number"><span class="nobr">Status</span></th>
    				<th class="order-date"><span class="nobr">Name</span></th>
    				<th class="order-status"><span class="nobr">Email</span></th>
    				<th class="order-total"><span class="nobr">Phone</span></th>
    				<th class="order-actions"><span class="nobr">Qty</span></th>
    				</tr>
    				</thead>
    				<tbody>
    				';
    
    				foreach ($customerList as $orderID => $totalAttendees) {
    					$order = new WC_Order($orderID);
    					$attendees = "$totalAttendees";
    					$frontend_attendees .= '<tr class="order">';
    					//Order Status
    					$frontend_attendees .= '<td class="order-number" data-title="Order Number">';
    					$frontend_attendees .= $order->status;
    					$frontend_attendees .= "</td>";
    					//Customer Name
    					$frontend_attendees .= '<td class="order-date" data-title="Date">';
    					$frontend_attendees .= $order->billing_first_name;
    					$frontend_attendees .= "&nbsp;";
    					$frontend_attendees .= $order->billing_last_name;
    					$frontend_attendees .= "</td>";
    					//Billing Email
    					$frontend_attendees .= '<td class="order-status" data-title="Status" style="text-align:left; white-space:nowrap;">';
    					$frontend_attendees .= $order->billing_email;
    					$frontend_attendees .= "</td>";
    					//Billing Phone
    					$frontend_attendees .= '<td class="order-total" data-title="Total">';
    					$frontend_attendees .= $order->billing_phone;
    					$frontend_attendees .= "</td>";
    					//Total Tickets Purchased
    					$frontend_attendees .= '<td class="order-actions">';
    					$frontend_attendees .= $attendees;
    					$frontend_attendees .= "</td>";
    					$frontend_attendees .= '</tr>';
    					// $frontend_attendees .= "{$order->billing_first_name} {$order->billing_last_name} {$order->billing_email} {$order->billing_phone} &ndash; $attendees";
    				}
    
    				$frontend_attendees .= '
    				</tbody>
    				</table>
    				</div>
    				';
    				$post->post_content .= $frontend_attendees;
    			}
    		}
    	}
    }
    
    ?>
    
    #992146
    Brian
    Keymaster

    I am glad to see you found that solution and thanks for sharing.

    I am going to go ahead and close this ticket. If you have a similar issue or another in the future, please do not hesitate to create a new ticket.

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Display attendees at frontend?’ is closed to new replies.