diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/community/class-login-handler.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/community/class-login-handler.php index ab58f906..13858ce5 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/community/class-login-handler.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/community/class-login-handler.php @@ -169,9 +169,15 @@ class Login_Handler { public function custom_login_redirect( $redirect_to, $requested_redirect_to, $user ) { // Check if login was successful and user is not an error object if ( $user && ! is_wp_error( $user ) ) { + // Check if the user has Master Trainer capabilities - redirect to Master Dashboard first + if ( user_can( $user, 'view_master_dashboard' ) || user_can( $user, 'view_all_trainer_data' ) ) { + // Redirect Master Trainers to the Master Dashboard + $master_dashboard_url = home_url( '/master-dashboard/' ); + return $master_dashboard_url; + } // Check if the user has the 'hvac_trainer' role - if ( in_array( 'hvac_trainer', (array) $user->roles ) ) { - // Redirect HVAC trainers to their dashboard + elseif ( in_array( 'hvac_trainer', (array) $user->roles ) ) { + // Redirect regular HVAC trainers to their dashboard // Assumes dashboard page slug is 'hvac-dashboard'. Adjust if needed. $dashboard_url = home_url( '/hvac-dashboard/' ); return $dashboard_url; @@ -197,9 +203,14 @@ class Login_Handler { // Get current user $user = wp_get_current_user(); - // Redirect based on user role/capabilities - if ( in_array( 'hvac_trainer', (array) $user->roles ) || current_user_can( 'view_hvac_dashboard' ) ) { - // HVAC trainers go to their dashboard + // Redirect based on user role/capabilities - prioritize Master Trainers + if ( current_user_can( 'view_master_dashboard' ) || current_user_can( 'view_all_trainer_data' ) ) { + // Master Trainers go to the Master Dashboard + $master_dashboard_url = home_url( '/master-dashboard/' ); + wp_safe_redirect( $master_dashboard_url ); + exit; + } elseif ( in_array( 'hvac_trainer', (array) $user->roles ) || current_user_can( 'view_hvac_dashboard' ) ) { + // Regular HVAC trainers go to their dashboard $dashboard_url = home_url( '/hvac-dashboard/' ); wp_safe_redirect( $dashboard_url ); exit; diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php index d6215329..97d52692 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-dashboard.php @@ -123,6 +123,12 @@ get_header(); // Use theme's header 'View Profile', 'Update your professional credentials, business information, and training specialties' ); ?> + + Master Dashboard', + 'Access the Master Trainer Dashboard to view system-wide analytics and manage all trainers' + ); ?> + Help Logout diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-master-dashboard.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-master-dashboard.php index 8b294f4e..727a8c37 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-master-dashboard.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/templates/template-hvac-master-dashboard.php @@ -143,7 +143,7 @@ if ( isset( $_GET['error'] ) && $_GET['error'] === 'access_denied' ) { Templates - Your Dashboard + Trainer Dashboard Logout