From 6f420815adcc1724e57499ec1b3b498dcd3399c5 Mon Sep 17 00:00:00 2001 From: bengizmo Date: Fri, 13 Jun 2025 19:16:19 -0300 Subject: [PATCH] Fix shortcode registration conflicts and add diagnostic tools MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove duplicate hvac_trainer_registration shortcode registration - Fix static vs instance method call in edit profile shortcode - Add debugging logs to track shortcode registration - Add comprehensive E2E test for trainer registration page - Clean up shortcode initialization order Issue persists with shortcode not being processed on frontend. Requires further investigation into WordPress shortcode processing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../e2e/trainer-registration-fix.test.ts | 92 +++++++++++++++++++ .../includes/class-hvac-community-events.php | 23 +++-- .../includes/class-hvac-registration.php | 5 +- 3 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 wordpress-dev/tests/e2e/trainer-registration-fix.test.ts diff --git a/wordpress-dev/tests/e2e/trainer-registration-fix.test.ts b/wordpress-dev/tests/e2e/trainer-registration-fix.test.ts new file mode 100644 index 00000000..f4f06be5 --- /dev/null +++ b/wordpress-dev/tests/e2e/trainer-registration-fix.test.ts @@ -0,0 +1,92 @@ +import { test, expect } from '@playwright/test'; +import { CommonActions } from './utils/common-actions'; + +/** + * Trainer Registration Page Fix Test + */ + +test.describe('Trainer Registration Page Tests', () => { + + test('Check trainer registration page content', async ({ page }) => { + test.setTimeout(20000); + const actions = new CommonActions(page); + + // Navigate to trainer registration page + await page.goto('https://upskill-staging.measurequick.com/trainer-registration/'); + await page.waitForLoadState('networkidle'); + + await actions.screenshot('trainer-registration-page'); + + const url = page.url(); + console.log('Trainer Registration URL:', url); + + // Check for page content + const bodyText = await page.textContent('body'); + console.log('Page contains shortcode text:', bodyText.includes('[') ? '⚠ Shortcode visible' : '✓ No visible shortcodes'); + + // Check for registration form elements + const hasForm = await page.locator('form').count() > 0; + const hasInputs = await page.locator('input[type="text"], input[type="email"], input[type="password"]').count() > 0; + + console.log('Registration form present:', hasForm ? '✓' : '✗'); + console.log('Form inputs present:', hasInputs ? '✓' : '✗'); + + // Check for specific registration form fields + const expectedFields = [ + 'username', 'user_login', 'email', 'user_email', + 'password', 'user_pass', 'first_name', 'last_name' + ]; + + let fieldCount = 0; + for (const field of expectedFields) { + const fieldExists = await page.locator(`input[name="${field}"], input[id="${field}"]`).count() > 0; + if (fieldExists) fieldCount++; + } + + console.log(`Registration form fields found: ${fieldCount}/${expectedFields.length}`); + + // Check for shortcode content vs rendered form + const hasShortcodeBrackets = bodyText.includes('[hvac_trainer_registration]'); + console.log('Raw shortcode visible:', hasShortcodeBrackets ? '⚠ YES - Issue detected' : '✓ NO - Properly rendered'); + + // Look for WordPress form elements + const hasWPElements = await page.locator('.wp-block, .entry-content, .ast-container').count() > 0; + console.log('WordPress structure:', hasWPElements ? '✓' : '✗'); + + if (hasShortcodeBrackets) { + console.log('🔍 ISSUE FOUND: Raw shortcode [hvac_trainer_registration] is visible on page'); + console.log('📝 This indicates the shortcode is not being processed properly'); + } + }); + + test('Check for specific shortcode processing issues', async ({ page }) => { + test.setTimeout(15000); + const actions = new CommonActions(page); + + await page.goto('https://upskill-staging.measurequick.com/trainer-registration/'); + await page.waitForLoadState('networkidle'); + + // Get the full HTML to analyze + const htmlContent = await page.content(); + + // Check for various shortcode patterns + const shortcodePatterns = [ + '[hvac_trainer_registration]', + '', + '[tribe_community_events', + 'shortcode' + ]; + + console.log('\n=== Shortcode Analysis ==='); + for (const pattern of shortcodePatterns) { + const found = htmlContent.includes(pattern); + console.log(`Pattern "${pattern}": ${found ? '⚠ FOUND' : '✓ Not found'}`); + } + + // Check if the page is loading through correct template + const hasCustomTemplate = htmlContent.includes('hvac') || htmlContent.includes('trainer'); + console.log(`Custom template indicators: ${hasCustomTemplate ? '✓ Present' : '✗ Missing'}`); + + await actions.screenshot('trainer-registration-analysis'); + }); +}); \ No newline at end of file diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php index dda01cce..00b57fa4 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-community-events.php @@ -13,6 +13,11 @@ class HVAC_Community_Events { */ private static $instance = null; + /** + * Registration instance + */ + private $registration = null; + /** * Main instance */ @@ -203,7 +208,7 @@ class HVAC_Community_Events { } // Check if user has master dashboard permissions (same as master dashboard) - if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('administrator')) { + if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('manage_options')) { // Redirect to regular dashboard or show error wp_redirect(home_url('/hvac-dashboard/?error=access_denied')); exit; @@ -250,10 +255,10 @@ class HVAC_Community_Events { $this->init_admin_dashboard(); } - // Initialize forms + // Initialize forms first $this->init_forms(); - // Initialize shortcodes + // Initialize shortcodes after forms are ready $this->init_shortcodes(); // Initialize certificate AJAX handler @@ -337,7 +342,9 @@ class HVAC_Community_Events { * Initialize forms */ private function init_forms() { - $registration = new HVAC_Registration(); + error_log('[HVAC DEBUG] Initializing HVAC_Registration class'); + $this->registration = new HVAC_Registration(); + error_log('[HVAC DEBUG] HVAC_Registration class initialized'); // Note: Form registration is handled in the class constructor } @@ -345,8 +352,7 @@ class HVAC_Community_Events { * Initialize shortcodes */ private function init_shortcodes() { - // Registration form shortcode - add_shortcode('hvac_trainer_registration', array('HVAC_Registration', 'render_registration_form')); + // Note: Registration form shortcode is registered in HVAC_Registration constructor // Community login shortcode - initialize Login_Handler to register the shortcode new \HVAC_Community_Events\Community\Login_Handler(); @@ -363,8 +369,7 @@ class HVAC_Community_Events { // Add trainer profile shortcode add_shortcode('hvac_trainer_profile', array($this, 'render_trainer_profile')); - // Add edit profile shortcode - add_shortcode('hvac_edit_profile', array('HVAC_Registration', 'render_edit_profile_form')); + // Note: Edit profile shortcode is registered in HVAC_Registration constructor // Add email attendees shortcode add_shortcode('hvac_email_attendees', array($this, 'render_email_attendees')); @@ -748,7 +753,7 @@ class HVAC_Community_Events { } // Check if user has master dashboard permissions - if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('administrator')) { + if (!current_user_can('view_master_dashboard') && !current_user_can('view_all_trainer_data') && !current_user_can('manage_options')) { return '

You do not have permission to access Google Sheets integration.

'; } diff --git a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-registration.php b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-registration.php index f6f94317..da4404aa 100644 --- a/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-registration.php +++ b/wordpress-dev/wordpress/wp-content/plugins/hvac-community-events/includes/class-hvac-registration.php @@ -21,8 +21,11 @@ class HVAC_Registration { // Register shortcode for registration form add_shortcode('hvac_trainer_registration', array($this, 'render_registration_form')); - // Register shortcode for edit profile form + // Register shortcode for edit profile form add_shortcode('hvac_edit_profile', array($this, 'render_edit_profile_form')); + + // Log shortcode registration + error_log('[HVAC DEBUG] Shortcodes registered in HVAC_Registration constructor'); // Enqueue styles and scripts add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));