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
This commit is contained in:
@@ -438,6 +438,18 @@ class DDHH_JM_Notifications {
|
|||||||
return;
|
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
|
// Get opted-in mentors
|
||||||
$mentor_ids = DDHH_JM_User_Preferences::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
|
// Schedule async batch notifications
|
||||||
$batch_count = DDHH_JM_Scheduler::schedule_mentor_notification_batch( $mentor_ids, $post->ID );
|
$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
|
// Log success
|
||||||
error_log(
|
error_log(
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|||||||
Reference in New Issue
Block a user