'; // Ensure user is logged in and has access to the master dashboard if ( ! is_user_logged_in() ) { // Redirect to login page if not logged in wp_safe_redirect( home_url( '/training-login/' ) ); exit; } // Check if user has permission to view master dashboard - check roles instead of capabilities $current_user = wp_get_current_user(); if ( ! in_array( 'hvac_master_trainer', $current_user->roles ) && ! current_user_can( 'manage_options' ) ) { // Show access denied message using existing styles get_header(); ?>

Access Denied

You do not have permission to view the Master Dashboard.

This dashboard is only available to Master Trainers and Administrators.

Go to Your Dashboard Return to Home
ID; // Check for approval message $approval_message = get_transient( 'hvac_approval_message' ); if ( $approval_message ) { delete_transient( 'hvac_approval_message' ); } // Load master dashboard data class if ( ! class_exists( 'HVAC_Master_Dashboard_Data' ) ) { require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-master-dashboard-data.php'; } // Load trainer status class if ( ! class_exists( 'HVAC_Trainer_Status' ) ) { require_once HVAC_PLUGIN_DIR . 'includes/class-hvac-trainer-status.php'; } // Initialize master dashboard data handler (no user ID needed - shows all data) $master_data = new HVAC_Master_Dashboard_Data(); // Get statistics $total_events = $master_data->get_total_events_count(); $upcoming_events = $master_data->get_upcoming_events_count(); $past_events = $master_data->get_past_events_count(); $total_tickets_sold = $master_data->get_total_tickets_sold(); $total_revenue = $master_data->get_total_revenue(); $trainer_stats = $master_data->get_trainer_statistics(); // Get events table data (default view) $default_args = array( 'status' => 'all', 'orderby' => 'date', 'order' => 'DESC', 'page' => 1, 'per_page' => 10 ); $events_table_data = $master_data->get_events_table_data( $default_args ); // Get list of all trainers for filter dropdown $all_trainers = get_users(array( 'role__in' => array('hvac_trainer', 'hvac_master_trainer'), 'fields' => array('ID', 'display_name') )); // Error handling for access denied $error_message = ''; if ( isset( $_GET['error'] ) && $_GET['error'] === 'access_denied' ) { $error_message = 'You were redirected here because you do not have permission to access the Master Dashboard.'; } // Note: get_header() is called by the main page template ?>

System Overview

Total Events

Upcoming Events

Completed Events

Active Trainers

Tickets Sold

Total Revenue

$

Trainer Performance Analytics

Loading trainers...

All Events Management

Loading events...