From 8adc3ac8e43ec88cff3f9a7028c85085113b23f0 Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 20 Feb 2026 12:42:34 -0400 Subject: [PATCH] fix(registration): Remove hardcoded page IDs causing login redirect The registration page (ID 5334 on staging) was incorrectly matched by HVAC_Event_Manager::isManagePage() which had is_page(5334) as a legacy check. This caused non-logged-in users to be redirected to the login page instead of seeing the public registration form. Removed hardcoded page IDs from isManagePage() and isEditPage() in favor of URL/slug detection which is environment-independent. Co-Authored-By: Claude Opus 4.6 --- includes/class-hvac-access-control.php | 8 ++++---- includes/class-hvac-event-manager.php | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/includes/class-hvac-access-control.php b/includes/class-hvac-access-control.php index 2bb9f474..0179f169 100644 --- a/includes/class-hvac-access-control.php +++ b/includes/class-hvac-access-control.php @@ -73,23 +73,23 @@ class HVAC_Access_Control { public function check_page_access() { // Get current page path $current_path = trim( parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ), '/' ); - + // Check if this is a legacy URL that will be redirected if ( $this->is_legacy_url( $current_path ) ) { // Allow the redirect to happen first return; } - + // Check if this is a public page if ( $this->is_public_page( $current_path ) ) { return; } - + // Check if this is a trainer page if ( $this->is_trainer_page( $current_path ) ) { $this->check_trainer_access( $current_path ); } - + // Check if this is a master trainer page if ( $this->is_master_trainer_page( $current_path ) ) { $this->check_master_trainer_access( $current_path ); diff --git a/includes/class-hvac-event-manager.php b/includes/class-hvac-event-manager.php index 45a8eaa5..69b36bb9 100644 --- a/includes/class-hvac-event-manager.php +++ b/includes/class-hvac-event-manager.php @@ -135,7 +135,7 @@ final class HVAC_Event_Manager { // Event management (creation) page if ($this->isManagePage()) { - $custom_template = HVAC_PLUGIN_DIR . 'templates/page-trainer-event-manage.php'; + $custom_template = HVAC_PLUGIN_DIR . 'templates/page-manage-event.php'; if (file_exists($custom_template)) { return $custom_template; } @@ -165,13 +165,12 @@ final class HVAC_Event_Manager { */ private function isManagePage(): bool { $request_uri = $_SERVER['REQUEST_URI'] ?? ''; - + return ( strpos($request_uri, '/trainer/event/manage') !== false || get_query_var('hvac_event_manage') === '1' || is_page('manage-event') || - is_page('trainer-event-manage') || - is_page(5334) // Legacy page ID + is_page('trainer-event-manage') ); } @@ -180,11 +179,10 @@ final class HVAC_Event_Manager { */ private function isEditPage(): bool { $request_uri = $_SERVER['REQUEST_URI'] ?? ''; - + return ( strpos($request_uri, '/trainer/event/edit') !== false || get_query_var('hvac_event_edit') === '1' || - is_page(6177) || // Configuration-based page ID (is_page() && get_page_template_slug() === 'templates/page-edit-event-custom.php') ); }