#!/bin/bash # Exit on error set -e # Source environment variables if [ -f ".env" ]; then source .env else echo "Error: .env file not found. Please create it with the required variables." exit 1 fi echo "===== Testing Login Form =====" # Create a script to test the login form rendering sshpass -p "$UPSKILL_STAGING_PASS" ssh -o StrictHostKeyChecking=no "$UPSKILL_STAGING_SSH_USER@$UPSKILL_STAGING_IP" "cd $UPSKILL_STAGING_PATH && cat > test-login-form.php << 'EOF' 'wp_login_form(', 'form_id' => 'form_id', 'redirect' => 'redirect', 'login-error' => 'login-error', 'login=failed' => 'login=failed' ); echo "\nChecking for critical components:\n"; foreach ($check_items as $name => $pattern) { echo "$name: " . (strpos($content, $pattern) !== false ? "FOUND" : "NOT FOUND") . "\n"; } } else { echo "Login template NOT found at: $template_path\n"; } // Check the page template $page_template_path = WP_CONTENT_DIR . '/plugins/hvac-community-events/templates/page-community-login.php'; if (file_exists($page_template_path)) { echo "\nPage template exists at: $page_template_path\n"; // Display template content $content = file_get_contents($page_template_path); echo "\nPage template content:\n" . substr($content, 0, 500) . "...\n"; // Check for critical components $check_items = array( 'Login_Handler' => 'Login_Handler', 'render_login_form' => 'render_login_form', 'shortcode' => 'shortcode' ); echo "\nChecking for critical components:\n"; foreach ($check_items as $name => $pattern) { echo "$name: " . (strpos($content, $pattern) !== false ? "FOUND" : "NOT FOUND") . "\n"; } } else { echo "Page template NOT found at: $page_template_path\n"; } // Test if shortcode is registered echo "\nTesting if the login shortcode is registered:\n"; $shortcodes = array_keys($GLOBALS['shortcode_tags']); echo "Registered shortcodes: " . implode(', ', $shortcodes) . "\n"; echo "hvac_community_login shortcode is " . (in_array('hvac_community_login', $shortcodes) ? "registered" : "NOT registered") . "\n"; // Test the render_login_form method directly echo "\nTesting login form rendering directly:\n"; if (class_exists('\\HVAC_Community_Events\\Community\\Login_Handler')) { $login_handler = new \\HVAC_Community_Events\\Community\\Login_Handler(); if (method_exists($login_handler, 'render_login_form')) { echo "Login handler has render_login_form method\n"; // Capture output ob_start(); $form = $login_handler->render_login_form(array()); ob_end_clean(); echo "Form output length: " . strlen($form) . " characters\n"; echo "Form contains form tag: " . (strpos($form, '