From 8db1881a38cb916f1ef736736f43e0c169b07bd2 Mon Sep 17 00:00:00 2001 From: ben Date: Wed, 24 Sep 2025 14:30:16 -0300 Subject: [PATCH] fix: implement correct TEC 5.0+ hooks for Community Events integration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update hook names from tribe_* to tec_* prefix for TEC 5.0+ compatibility - Replace non-existent tribe_events_community_submission_before_save with actual tec_events_community_before_save_submission - Replace non-existent tribe_events_community_submission_success with actual tribe_community_event_save_updated - Update method signatures to match correct hook parameters - Maintain WordPress transient caching implementation for performance - Remove JavaScript form override to prevent security conflicts - Add proper debug logging for hook validation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/settings.local.json | 17 ++- assets/js/hvac-rest-api-event-submission.js | 80 +++++++++++---- includes/class-hvac-ajax-handlers.php | 96 ++++++++++++++++- includes/class-hvac-plugin.php | 108 +++++++++++++++++++- 4 files changed, 274 insertions(+), 27 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 45ecc43d..02fe19cb 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -43,7 +43,22 @@ "mcp__playwright__browser_evaluate", "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp user update test_master --user_pass=master123\")", "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp user update test_master --user_pass=MasterTrainer2024!\")", - "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e scp -o StrictHostKeyChecking=no /home/ben/dev/upskill-event-manager/templates/page-master-trainers.php roodev@146.190.76.204:/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/templates/)" + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e scp -o StrictHostKeyChecking=no /home/ben/dev/upskill-event-manager/templates/page-master-trainers.php roodev@146.190.76.204:/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/templates/)", + "WebFetch(domain:upskill-staging.measurequick.com)", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp user get test_trainer --field=capabilities\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e scp -o StrictHostKeyChecking=no /home/ben/dev/upskill-event-manager/includes/class-hvac-plugin.php roodev@146.190.76.204:/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/includes/)", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e scp -o StrictHostKeyChecking=no /home/ben/dev/upskill-event-manager/includes/class-hvac-ajax-handlers.php roodev@146.190.76.204:/home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/hvac-community-events/includes/)", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"tail -100 /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/debug.log | grep -i -E ''(TEC|Security|tribe|filter|hook)''\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"tail -200 /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/debug.log | grep -E ''(HVAC TEC|TEC Integration|TEC Debug)''\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp plugin list | grep -E ''event|tribe|community''\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"find /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/the-events-calendar-community-events -name ''*.php'' -exec grep -l ''do_action.*submit\\|apply_filters.*submit'' {} \\;\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"grep -n -A5 -B5 ''do_action.*submit\\|apply_filters.*submit'' /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/the-events-calendar-community-events/src/Tribe/Main.php\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"find /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/the-events-calendar-community-events -name ''*.php'' -exec grep -l ''submission.*handler\\|form.*submit\\|event.*save'' {} \\;\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"grep -n -A20 -B5 ''do_action\\|apply_filters'' /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/plugins/the-events-calendar-community-events/src/Events_Community/Submission/Save.php\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp option get tribe_events_community_options | grep -E ''communityRewriteSlug|eventsDefaultStatus''\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp post list --post_type=tribe_events --posts_per_page=5 --format=table\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"cd /home/974670.cloudwaysapps.com/uberrxmprk/public_html && wp post create --post_type=tribe_events --post_title=''Test Hook Integration'' --post_content=''Testing TEC hook integration'' --post_excerpt=''Test excerpt for hook validation'' --post_status=publish --format=ids\")", + "Bash(SSHPASS=\"uSCO6f1y\" sshpass -e ssh -o StrictHostKeyChecking=no roodev@146.190.76.204 \"tail -30 /home/974670.cloudwaysapps.com/uberrxmprk/public_html/wp-content/debug.log\")" ], "deny": [], "ask": [], diff --git a/assets/js/hvac-rest-api-event-submission.js b/assets/js/hvac-rest-api-event-submission.js index 3f2dfe52..df2d3e54 100644 --- a/assets/js/hvac-rest-api-event-submission.js +++ b/assets/js/hvac-rest-api-event-submission.js @@ -68,32 +68,68 @@ }, /** - * Attach submit handler to intercept form submission + * Initialize form enhancement without overriding TEC submission + * + * Uses WordPress filter hooks for TEC integration instead of JavaScript overrides. + * This prevents "Security check failed" errors by maintaining TEC's native security flow. */ attachSubmitHandler: function() { - const self = this; - - // TEMPORARILY DISABLED: Override TEC form submission - // This override was causing 500 "Security check failed" errors - // because it bypasses TEC's native security token validation - // TODO: Implement proper WordPress filter-based approach instead - /* - $(document).on('submit', '#tribe-community-events form', function(e) { - e.preventDefault(); - console.log('[HVAC REST] Intercepting form submission for REST API'); + console.log('[HVAC REST] TEC form enhancement initialized - using WordPress filter hooks for integration'); - // Collect all form data - const eventData = self.collectFormData($(this)); - - // Submit via REST API - self.submitViaRestAPI(eventData); - - return false; - }); - */ - console.log('[HVAC REST] Form override disabled - using TEC native submission'); + // Enhance form with additional UI improvements without intercepting submission + this.enhanceFormUI(); }, - + + /** + * Enhance form UI without intercepting submission + * + * Provides visual feedback and validation while preserving TEC native functionality + */ + enhanceFormUI: function() { + const $form = $('#tribe-community-events form'); + + if (!$form.length) { + console.log('[HVAC REST] TEC form not found for UI enhancement'); + return; + } + + // Add visual feedback for form submission (without prevention) + $form.on('submit', function() { + console.log('[HVAC REST] Form submitted - TEC handling natively with WordPress filters'); + }); + + // Enhance excerpt field if present + const $excerptField = $form.find('[name="excerpt"]'); + if ($excerptField.length) { + $excerptField.attr('placeholder', 'Brief event description...'); + } + + // Add form validation helpers (non-blocking) + this.addFormValidationHelpers($form); + }, + + /** + * Add non-blocking form validation helpers + */ + addFormValidationHelpers: function($form) { + // Add visual feedback for required fields + $form.find('input[required], textarea[required]').on('blur', function() { + const $field = $(this); + if (!$field.val().trim()) { + $field.addClass('hvac-field-warning'); + } else { + $field.removeClass('hvac-field-warning'); + } + }); + + // Add CSS for validation styling + if (!$('style#hvac-form-validation').length) { + $('