Fix shortcode registration conflicts and add diagnostic tools
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
f69146432c
commit
6f420815ad
3 changed files with 110 additions and 10 deletions
92
wordpress-dev/tests/e2e/trainer-registration-fix.test.ts
Normal file
92
wordpress-dev/tests/e2e/trainer-registration-fix.test.ts
Normal file
|
|
@ -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]',
|
||||||
|
'<!-- wp:shortcode -->',
|
||||||
|
'[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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -13,6 +13,11 @@ class HVAC_Community_Events {
|
||||||
*/
|
*/
|
||||||
private static $instance = null;
|
private static $instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registration instance
|
||||||
|
*/
|
||||||
|
private $registration = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main instance
|
* Main instance
|
||||||
*/
|
*/
|
||||||
|
|
@ -203,7 +208,7 @@ class HVAC_Community_Events {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if user has master dashboard permissions (same as master dashboard)
|
// 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
|
// Redirect to regular dashboard or show error
|
||||||
wp_redirect(home_url('/hvac-dashboard/?error=access_denied'));
|
wp_redirect(home_url('/hvac-dashboard/?error=access_denied'));
|
||||||
exit;
|
exit;
|
||||||
|
|
@ -250,10 +255,10 @@ class HVAC_Community_Events {
|
||||||
$this->init_admin_dashboard();
|
$this->init_admin_dashboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize forms
|
// Initialize forms first
|
||||||
$this->init_forms();
|
$this->init_forms();
|
||||||
|
|
||||||
// Initialize shortcodes
|
// Initialize shortcodes after forms are ready
|
||||||
$this->init_shortcodes();
|
$this->init_shortcodes();
|
||||||
|
|
||||||
// Initialize certificate AJAX handler
|
// Initialize certificate AJAX handler
|
||||||
|
|
@ -337,7 +342,9 @@ class HVAC_Community_Events {
|
||||||
* Initialize forms
|
* Initialize forms
|
||||||
*/
|
*/
|
||||||
private function init_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
|
// Note: Form registration is handled in the class constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,8 +352,7 @@ class HVAC_Community_Events {
|
||||||
* Initialize shortcodes
|
* Initialize shortcodes
|
||||||
*/
|
*/
|
||||||
private function init_shortcodes() {
|
private function init_shortcodes() {
|
||||||
// Registration form shortcode
|
// Note: Registration form shortcode is registered in HVAC_Registration constructor
|
||||||
add_shortcode('hvac_trainer_registration', array('HVAC_Registration', 'render_registration_form'));
|
|
||||||
|
|
||||||
// Community login shortcode - initialize Login_Handler to register the shortcode
|
// Community login shortcode - initialize Login_Handler to register the shortcode
|
||||||
new \HVAC_Community_Events\Community\Login_Handler();
|
new \HVAC_Community_Events\Community\Login_Handler();
|
||||||
|
|
@ -363,8 +369,7 @@ class HVAC_Community_Events {
|
||||||
// Add trainer profile shortcode
|
// Add trainer profile shortcode
|
||||||
add_shortcode('hvac_trainer_profile', array($this, 'render_trainer_profile'));
|
add_shortcode('hvac_trainer_profile', array($this, 'render_trainer_profile'));
|
||||||
|
|
||||||
// Add edit profile shortcode
|
// Note: Edit profile shortcode is registered in HVAC_Registration constructor
|
||||||
add_shortcode('hvac_edit_profile', array('HVAC_Registration', 'render_edit_profile_form'));
|
|
||||||
|
|
||||||
// Add email attendees shortcode
|
// Add email attendees shortcode
|
||||||
add_shortcode('hvac_email_attendees', array($this, 'render_email_attendees'));
|
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
|
// 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 '<p>You do not have permission to access Google Sheets integration.</p>';
|
return '<p>You do not have permission to access Google Sheets integration.</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ class HVAC_Registration {
|
||||||
// Register shortcode for edit profile form
|
// Register shortcode for edit profile form
|
||||||
add_shortcode('hvac_edit_profile', array($this, 'render_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
|
// Enqueue styles and scripts
|
||||||
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
|
add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue