diff --git a/Status.md b/Status.md index 6adc45cb..9907e9cf 100644 --- a/Status.md +++ b/Status.md @@ -1,12 +1,60 @@ # HVAC Community Events - Project Status -**Last Updated:** January 5, 2026 -**Current Session:** TEC Community Events Dependency Analysis - Complete -**Version:** 2.1.11 (Deployed to Production) +**Last Updated:** January 9, 2026 +**Current Session:** Master Trainer Profile Edit Enhancement - Complete +**Version:** 2.1.12 (Deployed to Production) --- -## 🎯 CURRENT SESSION - TEC COMMUNITY EVENTS DEPENDENCY ANALYSIS (Jan 5, 2026) +## 🎯 CURRENT SESSION - MASTER TRAINER PROFILE EDIT ENHANCEMENT (Jan 9, 2026) + +### Status: ✅ **COMPLETE - Deployed to Production** + +**Objective:** Fix broken button styling and add all trainer profile fields to the master trainer profile edit page. + +**Issues Fixed:** +1. **Button Styling Broken** - "Back to Dashboard" and "Cancel" buttons appeared faded/invisible due to CSS conflicts with theme +2. **Missing Profile Fields** - Only showing basic name fields, needed all trainer profile fields +3. **No Password Reset** - Master trainers couldn't trigger password resets for trainers they manage + +### Changes Made + +1. ✅ **Fixed Button Styling** (`templates/page-master-trainer-profile-edit-simple.php`) + - Added scoped CSS with new class names (`hvac-btn-primary`, `hvac-btn-secondary`, `hvac-btn-outline`) + - Avoids theme CSS conflicts by using page-specific selectors + - Proper colors, hover states, and responsive behavior + +2. ✅ **Added All Profile Fields** (6 complete sections) + - **Profile Settings:** Visibility (Public/Private) + - **Certification Information:** Status, Type, Date Certified + - **Personal Information:** Name, Email, LinkedIn URL, Bio + - **Professional Information:** Accreditation, Training Audience/Formats/Locations/Resources (checkboxes) + - **Business Information:** Business Type, Revenue Target, Application Details + - **Location Information:** City, State, Country, Coordinates with re-geocode button + +3. ✅ **Added Password Reset Button** + - New "Send Password Reset Email" button in Personal Information section + - Uses WordPress built-in `retrieve_password()` function + - Shows status feedback (Sending... / Sent! / Error) + - Requires master trainer or admin permissions + - All actions logged for audit trail + +4. ✅ **Added AJAX Handler** (`includes/class-hvac-ajax-handlers.php`) + - New `hvac_send_password_reset` endpoint + - Nonce verification, permission checks, input validation + - Secure implementation using WordPress core functions + +### Files Modified +- `templates/page-master-trainer-profile-edit-simple.php` - Complete rewrite with all fields +- `includes/class-hvac-ajax-handlers.php` - Added password reset handler + +### URLs +- **Production:** `https://upskillhvac.com/master-trainer/edit-trainer-profile/?user_id=75` +- **Staging:** `https://upskill-staging.measurequick.com/master-trainer/edit-trainer-profile/?user_id=75` + +--- + +## 📋 PREVIOUS SESSION - TEC COMMUNITY EVENTS DEPENDENCY ANALYSIS (Jan 5, 2026) ### Status: ✅ **COMPLETE - Documented as Technical Debt** diff --git a/includes/class-hvac-ajax-handlers.php b/includes/class-hvac-ajax-handlers.php index dba849f1..631b3db9 100644 --- a/includes/class-hvac-ajax-handlers.php +++ b/includes/class-hvac-ajax-handlers.php @@ -61,6 +61,10 @@ class HVAC_Ajax_Handlers { // Enhanced approval endpoint (wrapper for existing) add_action('wp_ajax_hvac_approve_trainer_v2', array($this, 'approve_trainer_secure')); add_action('wp_ajax_nopriv_hvac_approve_trainer_v2', array($this, 'unauthorized_access')); + + // Password reset endpoint for master trainers + add_action('wp_ajax_hvac_send_password_reset', array($this, 'send_password_reset')); + add_action('wp_ajax_nopriv_hvac_send_password_reset', array($this, 'unauthorized_access')); } /** @@ -960,6 +964,66 @@ class HVAC_Ajax_Handlers { $this->clear_trainer_stats_cache(); } } + + /** + * Send password reset email to a trainer + * + * Allows master trainers to trigger a password reset email for any trainer. + * Uses WordPress built-in password reset functionality. + */ + public function send_password_reset() { + // Verify nonce + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'hvac_profile_edit')) { + wp_send_json_error('Invalid security token', 403); + return; + } + + // Check if user is logged in + if (!is_user_logged_in()) { + wp_send_json_error('You must be logged in', 401); + return; + } + + // Check if user has permission (master trainer or admin) + $current_user = wp_get_current_user(); + if (!in_array('hvac_master_trainer', $current_user->roles) && !in_array('administrator', $current_user->roles)) { + wp_send_json_error('You do not have permission to perform this action', 403); + return; + } + + // Get target user ID + $user_id = isset($_POST['user_id']) ? absint($_POST['user_id']) : 0; + if (!$user_id) { + wp_send_json_error('Invalid user ID', 400); + return; + } + + // Get target user + $user = get_userdata($user_id); + if (!$user) { + wp_send_json_error('User not found', 404); + return; + } + + // Use WordPress built-in password reset + $result = retrieve_password($user->user_login); + + if (is_wp_error($result)) { + wp_send_json_error($result->get_error_message(), 500); + return; + } + + // Log the action + error_log(sprintf( + '[HVAC] Password reset email sent for user %d (%s) by master trainer %d (%s)', + $user_id, + $user->user_email, + $current_user->ID, + $current_user->user_login + )); + + wp_send_json_success('Password reset email sent to ' . $user->user_email); + } } // Initialize the handlers diff --git a/templates/page-master-trainer-profile-edit-simple.php b/templates/page-master-trainer-profile-edit-simple.php index 6cad4d66..104a36ae 100644 --- a/templates/page-master-trainer-profile-edit-simple.php +++ b/templates/page-master-trainer-profile-edit-simple.php @@ -1,7 +1,7 @@ get_profile_meta($profile->ID); + +// Get coordinates if available +$coordinates = null; +$geocoding_status = ['status' => 'unknown']; +if (class_exists('HVAC_Geocoding_Service')) { + try { + $geocoding_service = HVAC_Geocoding_Service::get_instance(); + $coordinates = $geocoding_service->get_coordinates($profile->ID); + $geocoding_status = $geocoding_service->get_geocoding_status($profile->ID); + } catch (Exception $e) { + error_log('Geocoding service error in master trainer profile edit: ' . $e->getMessage()); + } +} ?> + +