0) { $submission['post_author'] = $current_user_id; HVAC_Logger::info('Setting event author to current user: ' . $current_user_id, 'EventAuthor'); } } return $submission; } /** * Fix event author after creation * * @param int $event_id The event ID */ public function fix_event_author($event_id) { $event = get_post($event_id); if ($event && $event->post_type === 'tribe_events') { $current_user_id = get_current_user_id(); // If the event has no author or author is 0, set it to current user if (($event->post_author == 0 || empty($event->post_author)) && $current_user_id > 0) { wp_update_post(array( 'ID' => $event_id, 'post_author' => $current_user_id )); HVAC_Logger::info('Fixed event author for event ' . $event_id . ' to user ' . $current_user_id, 'EventAuthor'); } } } /** * Set post author when inserting tribe_events post * * @param array $data The post data * @param array $postarr The post array * @return array Modified post data */ public function set_post_author($data, $postarr) { // Only handle tribe_events posts if ($data['post_type'] === 'tribe_events') { $current_user_id = get_current_user_id(); // If no author is set and we have a logged-in user, set the author if ((empty($data['post_author']) || $data['post_author'] == 0) && $current_user_id > 0) { $data['post_author'] = $current_user_id; HVAC_Logger::info('Setting tribe_events post author to: ' . $current_user_id, 'EventAuthor'); } } return $data; } }