- 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>
73 lines
No EOL
2.1 KiB
PHP
73 lines
No EOL
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: Master Trainers
|
|
* Description: Template for the master trainer's all trainers management 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-trainers-page">';
|
|
echo '<div class="container">';
|
|
|
|
// Render the master trainers content
|
|
echo '<h1>All Trainers</h1>';
|
|
echo '<div class="hvac-master-trainers-content">';
|
|
|
|
// Debug: Check if shortcode function exists and render accordingly
|
|
echo '<!-- DEBUG: Master trainers page content -->';
|
|
if (function_exists('hvac_render_master_trainers')) {
|
|
echo '<p>Loading master trainers via function...</p>';
|
|
ob_start();
|
|
echo hvac_render_master_trainers();
|
|
$content = ob_get_clean();
|
|
echo $content;
|
|
} else {
|
|
echo '<p>Loading master trainers via shortcode...</p>';
|
|
ob_start();
|
|
echo do_shortcode('[hvac_master_trainers]');
|
|
$content = ob_get_clean();
|
|
if (empty(trim($content))) {
|
|
echo '<div class="hvac-notice">Master trainers shortcode is not available. Please contact an administrator.</div>';
|
|
} else {
|
|
echo $content;
|
|
}
|
|
}
|
|
|
|
echo '</div>'; // .hvac-master-trainers-content
|
|
echo '</div>'; // .container
|
|
echo '</div>'; // .hvac-page-wrapper
|
|
|
|
get_footer();
|