'; // Get current user ID $current_user_id = get_current_user_id(); $trainer_profile = get_user_meta($current_user_id, 'hvac_trainer_profile', true); // Get Events global $wpdb; $events_query = $wpdb->prepare(" SELECT DISTINCT p.ID, p.post_title FROM {$wpdb->posts} p WHERE p.post_type = 'tribe_events' AND p.post_status = 'publish' AND p.post_author = %d ORDER BY p.post_date DESC ", $current_user_id); $events = $wpdb->get_results($events_query); // Check for selected event $selected_event_id = isset($_GET['event_id']) ? absint($_GET['event_id']) : 0; $attendees = array(); if ($selected_event_id) { // Get attendees for the selected event $attendees_query = $wpdb->prepare(" SELECT a.*, c.certificate_number FROM {$wpdb->prefix}hvac_attendees a LEFT JOIN {$wpdb->prefix}hvac_certificates c ON a.id = c.attendee_id AND c.event_id = %d WHERE a.event_id = %d ORDER BY a.name ASC ", $selected_event_id, $selected_event_id); $attendees = $wpdb->get_results($attendees_query); } ?>