diff --git a/.claude/settings.local.json b/.claude/settings.local.json
index 355ed975..fb84b3db 100644
--- a/.claude/settings.local.json
+++ b/.claude/settings.local.json
@@ -117,7 +117,8 @@
"Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-master-trainer-pages.js)",
"Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-master-trainer-verification.js)",
"Bash(UPSKILL_STAGING_URL=\"https://upskill-staging.measurequick.com\" wp-cli.phar --url=$UPSKILL_STAGING_URL --ssh=root@upskill-staging.measurequick.com post list --post_type=page --search=\"master-trainer\" --fields=ID,post_title,post_name,post_status)",
- "Bash(UPSKILL_STAGING_URL=\"https://upskill-staging.measurequick.com\" wp --url=$UPSKILL_STAGING_URL --ssh=root@upskill-staging.measurequick.com post list --post_type=page --search=\"master\" --fields=ID,post_title,post_name,post_status)"
+ "Bash(UPSKILL_STAGING_URL=\"https://upskill-staging.measurequick.com\" wp --url=$UPSKILL_STAGING_URL --ssh=root@upskill-staging.measurequick.com post list --post_type=page --search=\"master\" --fields=ID,post_title,post_name,post_status)",
+ "Bash(DISPLAY=:0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.90WDB3 node test-master-trainer-debug.js)"
],
"deny": []
},
diff --git a/includes/class-hvac-community-events.php b/includes/class-hvac-community-events.php
index 506539d9..1c270a2a 100644
--- a/includes/class-hvac-community-events.php
+++ b/includes/class-hvac-community-events.php
@@ -246,8 +246,9 @@ class HVAC_Community_Events {
exit;
}
- // Check if user has master dashboard permissions - include administrator
- if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('administrator')) {
+ // Check if user has master dashboard permissions - check for role and admin
+ $user = wp_get_current_user();
+ if (!in_array('hvac_master_trainer', $user->roles) && !current_user_can('manage_options')) {
// Redirect to regular dashboard or show error
wp_redirect(home_url('/trainer/dashboard/?error=access_denied'));
exit;
diff --git a/templates/page-master-dashboard.php b/templates/page-master-dashboard.php
index 48a7cde5..16154d9e 100644
--- a/templates/page-master-dashboard.php
+++ b/templates/page-master-dashboard.php
@@ -42,8 +42,15 @@ if (class_exists('HVAC_Breadcrumbs')) {
echo '
';
echo '
';
-// Render the master dashboard content directly (bypassing shortcode processing)
+// 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 '';
+echo $dashboard_content;
+echo '';
echo '
'; // .container
echo '
'; // .hvac-page-wrapper
diff --git a/templates/page-master-events.php b/templates/page-master-events.php
index a3ab86d7..1376762b 100644
--- a/templates/page-master-events.php
+++ b/templates/page-master-events.php
@@ -46,11 +46,24 @@ echo '';
echo '
Events Management
';
echo '
';
-// For now, render the shortcode - this can be enhanced later with direct content
+// Debug: Check if shortcode function exists and render accordingly
+echo '';
if (function_exists('hvac_render_master_events')) {
+ echo '
Loading master events via function...
';
+ ob_start();
echo hvac_render_master_events();
+ $content = ob_get_clean();
+ echo $content;
} else {
+ echo '
Loading master events via shortcode...
';
+ ob_start();
echo do_shortcode('[hvac_master_events]');
+ $content = ob_get_clean();
+ if (empty(trim($content))) {
+ echo '
Master events shortcode is not available. Please contact an administrator.
';
+ } else {
+ echo $content;
+ }
}
echo '
'; // .hvac-master-events-content
diff --git a/templates/page-master-trainers.php b/templates/page-master-trainers.php
index 20b04a46..1cc9f8c5 100644
--- a/templates/page-master-trainers.php
+++ b/templates/page-master-trainers.php
@@ -46,11 +46,24 @@ echo '
';
echo '
All Trainers
';
echo '
';
-// For now, render the shortcode - this can be enhanced later with direct content
+// Debug: Check if shortcode function exists and render accordingly
+echo '';
if (function_exists('hvac_render_master_trainers')) {
+ echo '
Loading master trainers via function...
';
+ ob_start();
echo hvac_render_master_trainers();
+ $content = ob_get_clean();
+ echo $content;
} else {
+ echo '
Loading master trainers via shortcode...
';
+ ob_start();
echo do_shortcode('[hvac_master_trainers]');
+ $content = ob_get_clean();
+ if (empty(trim($content))) {
+ echo '
Master trainers shortcode is not available. Please contact an administrator.
';
+ } else {
+ echo $content;
+ }
}
echo '
'; // .hvac-master-trainers-content
diff --git a/templates/template-hvac-master-dashboard.php b/templates/template-hvac-master-dashboard.php
index 12ae8273..65e3125d 100644
--- a/templates/template-hvac-master-dashboard.php
+++ b/templates/template-hvac-master-dashboard.php
@@ -109,8 +109,7 @@ 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.';
}
-// Get WordPress header - CRITICAL for CSS loading
-get_header();
+// Note: get_header() is called by the main page template
?>
@@ -800,6 +799,5 @@ var ajaxurl = '';
\ No newline at end of file
diff --git a/test-master-trainer-debug.js b/test-master-trainer-debug.js
new file mode 100644
index 00000000..ca0df94e
--- /dev/null
+++ b/test-master-trainer-debug.js
@@ -0,0 +1,111 @@
+const { chromium } = require('playwright');
+
+(async () => {
+ console.log('š Debug master trainer pages with proper authentication...');
+
+ const browser = await chromium.launch({
+ headless: false,
+ slowMo: 1500
+ });
+
+ const page = await browser.newPage();
+
+ try {
+ // Step 1: Login properly
+ console.log('š Step 1: Logging in as test_master...');
+ await page.goto('https://upskill-staging.measurequick.com/training-login/');
+ await page.waitForTimeout(2000);
+
+ await page.fill('#user_login', 'test_master');
+ await page.fill('#user_pass', 'TestMaster123!');
+ await page.click('#wp-submit');
+ await page.waitForTimeout(5000);
+
+ // Verify login worked
+ const loginSuccess = await page.evaluate(() => {
+ return !window.location.href.includes('/training-login/');
+ });
+
+ console.log('ā
Login Status:', loginSuccess ? 'SUCCESS' : 'FAILED');
+ console.log('š Current URL after login:', await page.url());
+
+ if (!loginSuccess) {
+ console.log('ā Login failed, cannot proceed');
+ return;
+ }
+
+ // Step 2: Test master dashboard directly
+ console.log('\nš Step 2: Testing master dashboard...');
+ await page.goto('https://upskill-staging.measurequick.com/master-trainer/master-dashboard/');
+ await page.waitForTimeout(3000);
+
+ const dashboardTest = await page.evaluate(() => ({
+ title: document.title,
+ url: window.location.href,
+ hasContent: document.body.innerText.length > 200,
+ bodyText: document.body.innerText.substring(0, 500),
+ hasNavigation: !!document.querySelector('.hvac-trainer-menu'),
+ navItems: Array.from(document.querySelectorAll('.hvac-trainer-menu a')).length,
+ hasHvacWrapper: !!document.querySelector('.hvac-page-wrapper'),
+ isLoginPage: document.body.innerText.includes('Sign in to access')
+ }));
+
+ console.log('š Dashboard Test Results:');
+ console.log('- Title:', dashboardTest.title);
+ console.log('- URL:', dashboardTest.url);
+ console.log('- Has Content:', dashboardTest.hasContent);
+ console.log('- Is Login Page:', dashboardTest.isLoginPage);
+ console.log('- Has Navigation:', dashboardTest.hasNavigation);
+ console.log('- Nav Items:', dashboardTest.navItems);
+ console.log('- Has HVAC Wrapper:', dashboardTest.hasHvacWrapper);
+ console.log('- Body Preview:', dashboardTest.bodyText);
+
+ // Step 3: Test trainers page
+ console.log('\nš Step 3: Testing trainers page...');
+ await page.goto('https://upskill-staging.measurequick.com/master-trainer/trainers/');
+ await page.waitForTimeout(3000);
+
+ const trainersTest = await page.evaluate(() => ({
+ title: document.title,
+ url: window.location.href,
+ hasContent: document.body.innerText.length > 200,
+ isLoginPage: document.body.innerText.includes('Sign in to access'),
+ contentPreview: document.body.innerText.substring(0, 300)
+ }));
+
+ console.log('š Trainers Page Test:');
+ console.log('- Title:', trainersTest.title);
+ console.log('- URL:', trainersTest.url);
+ console.log('- Is Login Page:', trainersTest.isLoginPage);
+ console.log('- Content Preview:', trainersTest.contentPreview);
+
+ // Step 4: Test communication templates
+ console.log('\nš Step 4: Testing communication templates...');
+ await page.goto('https://upskill-staging.measurequick.com/master-trainer/communication-templates/');
+ await page.waitForTimeout(3000);
+
+ const templatesTest = await page.evaluate(() => ({
+ title: document.title,
+ url: window.location.href,
+ hasContent: document.body.innerText.length > 200,
+ isLoginPage: document.body.innerText.includes('Sign in to access'),
+ contentPreview: document.body.innerText.substring(0, 300)
+ }));
+
+ console.log('š Templates Page Test:');
+ console.log('- Title:', templatesTest.title);
+ console.log('- URL:', templatesTest.url);
+ console.log('- Is Login Page:', templatesTest.isLoginPage);
+ console.log('- Content Preview:', templatesTest.contentPreview);
+
+ // Keep browser open for inspection
+ console.log('\nš Keeping browser open for 30 seconds for inspection...');
+ await page.waitForTimeout(30000);
+
+ } catch (error) {
+ console.error('Error during testing:', error);
+ } finally {
+ await browser.close();
+ console.log('ā
Debug completed');
+ }
+})();
\ No newline at end of file
diff --git a/test-page-source-debug.js b/test-page-source-debug.js
new file mode 100644
index 00000000..6fd18c03
--- /dev/null
+++ b/test-page-source-debug.js
@@ -0,0 +1,76 @@
+const { chromium } = require('playwright');
+
+(async () => {
+ console.log('š Examining page source for debug information...');
+
+ const browser = await chromium.launch({
+ headless: false,
+ slowMo: 1000
+ });
+
+ const page = await browser.newPage();
+
+ try {
+ // Login first
+ console.log('š Logging in...');
+ await page.goto('https://upskill-staging.measurequick.com/training-login/');
+ await page.waitForTimeout(2000);
+
+ await page.fill('#user_login', 'test_master');
+ await page.fill('#user_pass', 'TestMaster123!');
+ await page.click('#wp-submit');
+ await page.waitForTimeout(3000);
+
+ // Go to dashboard
+ console.log('š Loading dashboard...');
+ await page.goto('https://upskill-staging.measurequick.com/master-trainer/master-dashboard/');
+ await page.waitForTimeout(3000);
+
+ // Get the full HTML source
+ const htmlSource = await page.content();
+
+ // Look for debug comments and content
+ console.log('\nš Source Code Analysis:');
+ console.log('- Total HTML length:', htmlSource.length);
+ console.log('- Contains "DEBUG: Dashboard content captured":', htmlSource.includes('DEBUG: Dashboard content captured'));
+ console.log('- Contains "hvac-page-wrapper":', htmlSource.includes('hvac-page-wrapper'));
+ console.log('- Contains "Master Dashboard" in body:', htmlSource.includes('
Master Dashboard
'));
+ console.log('- Contains "System Overview":', htmlSource.includes('System Overview'));
+
+ // Look for WordPress main content area
+ console.log('\nš WordPress Structure Analysis:');
+ console.log('- Contains #primary:', htmlSource.includes('id="primary"'));
+ console.log('- Contains #main:', htmlSource.includes('id="main"'));
+ console.log('- Contains .site-main:', htmlSource.includes('site-main'));
+ console.log('- Contains .entry-content:', htmlSource.includes('entry-content'));
+
+ // Look for error messages or blank content
+ const bodyMatch = htmlSource.match(/]*>([\s\S]*?)<\/body>/);
+ if (bodyMatch) {
+ const bodyContent = bodyMatch[1];
+ console.log('\nš Body Content Analysis:');
+ console.log('- Body content length:', bodyContent.length);
+ console.log('- Contains navigation menu:', bodyContent.includes('hvac-trainer-menu'));
+ console.log('- Contains WordPress footer:', bodyContent.includes('wp-footer'));
+ }
+
+ // Extract and show a snippet of the body content around where our content should be
+ const mainContentMatch = htmlSource.match(/
]*id="main"[^>]*>([\s\S]*?)<\/main>/);
+ if (mainContentMatch) {
+ console.log('\nš Main Content Area:');
+ console.log(mainContentMatch[1].substring(0, 500) + '...');
+ } else {
+ console.log('\nā No main content area found');
+ }
+
+ // Keep browser open briefly
+ console.log('\nš Keeping browser open for 10 seconds...');
+ await page.waitForTimeout(10000);
+
+ } catch (error) {
+ console.error('Error during analysis:', error);
+ } finally {
+ await browser.close();
+ console.log('ā
Analysis completed');
+ }
+})();
\ No newline at end of file