- Fixed capability check in check_master_dashboard_auth function
- Changed from custom capabilities to role-based check: hvac_master_trainer role
- Root cause: function was checking for capabilities that hvac_master_trainer role didn't have
- This was causing HTTP 302 redirects to login page instead of loading dashboard content
- Master trainer pages now properly authenticate users with hvac_master_trainer role
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Master Dashboard
|
|
* Description: Template for the master trainer dashboard page
|
|
*/
|
|
|
|
// Define constant to indicate we are in a page template
|
|
if (!defined('HVAC_IN_PAGE_TEMPLATE')) {
|
|
define('HVAC_IN_PAGE_TEMPLATE', true);
|
|
}
|
|
|
|
get_header();
|
|
|
|
// Check master trainer permissions FIRST
|
|
$user = wp_get_current_user();
|
|
if (!in_array('hvac_master_trainer', $user->roles) && !current_user_can('manage_options')) {
|
|
?>
|
|
<div class="hvac-page-wrapper">
|
|
<div class="container">
|
|
<h1>Access Denied</h1>
|
|
<p>You do not have permission to access this page.</p>
|
|
<p>If you believe this is an error, please contact an administrator.</p>
|
|
<a href="<?php echo home_url(); ?>" class="button">Return to Home</a>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
get_footer();
|
|
exit;
|
|
}
|
|
|
|
// Render master trainer navigation
|
|
if (class_exists('HVAC_Master_Menu_System')) {
|
|
$master_menu = HVAC_Master_Menu_System::instance();
|
|
$master_menu->render_master_menu();
|
|
}
|
|
|
|
// Render breadcrumbs
|
|
if (class_exists('HVAC_Breadcrumbs')) {
|
|
HVAC_Breadcrumbs::render();
|
|
}
|
|
|
|
echo '<div class="hvac-page-wrapper hvac-master-dashboard-page">';
|
|
echo '<div class="container">';
|
|
|
|
// Render the master dashboard content with output buffering to ensure proper rendering
|
|
ob_start();
|
|
include HVAC_PLUGIN_DIR . 'templates/template-hvac-master-dashboard.php';
|
|
$dashboard_content = ob_get_clean();
|
|
|
|
// Output the dashboard content with debug info
|
|
echo '<!-- DEBUG: Dashboard content captured -->';
|
|
echo $dashboard_content;
|
|
echo '<!-- DEBUG: Dashboard content end -->';
|
|
|
|
echo '</div>'; // .container
|
|
echo '</div>'; // .hvac-page-wrapper
|
|
|
|
get_footer();
|