From 4145a92ca7b8c888b38f072394639920790aeb16 Mon Sep 17 00:00:00 2001 From: Viktor Miller Date: Thu, 29 Jan 2026 14:28:00 +0900 Subject: [PATCH] fix(quick-002): prevent duplicate mentor notifications on job republish - Add post meta guard `_ddhh_mentors_notified` to track notification status - Check meta before scheduling notifications, skip if already notified - Set meta flag after successful batch scheduling - Prevents re-notification when job edited and republished (pending -> publish) - Maintains existing publish -> publish guard logic --- includes/class-notifications.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/includes/class-notifications.php b/includes/class-notifications.php index 16b7989..812cdf2 100644 --- a/includes/class-notifications.php +++ b/includes/class-notifications.php @@ -438,6 +438,18 @@ class DDHH_JM_Notifications { return; } + // Check if mentors have already been notified for this job + $already_notified = get_post_meta( $post->ID, '_ddhh_mentors_notified', true ); + if ( '1' === $already_notified ) { + error_log( + sprintf( + 'DDHH Job Manager: Skipping mentor notification for job #%d - mentors already notified on initial publish', + $post->ID + ) + ); + return; + } + // Get opted-in mentors $mentor_ids = DDHH_JM_User_Preferences::get_opted_in_mentors(); @@ -456,6 +468,9 @@ class DDHH_JM_Notifications { // Schedule async batch notifications $batch_count = DDHH_JM_Scheduler::schedule_mentor_notification_batch( $mentor_ids, $post->ID ); + // Mark job as having notified mentors to prevent duplicate notifications + update_post_meta( $post->ID, '_ddhh_mentors_notified', '1' ); + // Log success error_log( sprintf(