• This is more of a feature request, having only one option:

    “Send notification when post is published or updated”

    Is really a pain when it comes to a news portal website, having to rely on writers to uncheck a box on every post they have an update to so we don’t inundate visitors that have opted into the push notifications with multiple alerts is difficult, it’s just such an easy thing to forget to do. Why can’t there be two options, one option to send when post is published and an option to send when post is updated. We would almost never want to send an alert when a post is updated.

Viewing 1 replies (of 1 total)
  • // Remove OneSignal action for post updates
    function prevent_onesignal_notifications_on_update($new_status, $old_status, $post) {
    error_log("OneSignal Action Check: post_id={$post->ID}, new_status=$new_status, old_status=$old_status");
    if ($new_status === 'publish' && $old_status === 'publish') {
    remove_action('transition_post_status', 'onesignal_schedule_notification', 10, 3);
    error_log("OneSignal Action Removed: Blocked notification for post update (post_id={$post->ID})");
    }
    }
    add_action('transition_post_status', 'prevent_onesignal_notifications_on_update', 5, 3);

    // Set os_update meta for new publications and block for updates
    function override_onesignal_update_flag($new_status, $old_status, $post) {
    error_log("OneSignal Status Transition: post_id={$post->ID}, new_status=$new_status, old_status=$old_status");

    if ($new_status === 'publish' && $old_status === 'publish') {
    update_post_meta($post->ID, 'os_update', 0); // Disable notifications for updates
    error_log("OneSignal: Disabled os_update meta for post update (post_id={$post->ID})");
    } elseif ($new_status === 'publish' && $old_status !== 'publish') {
    update_post_meta($post->ID, 'os_update', 1); // Enable notifications for new publications
    error_log("OneSignal: Enabled os_update meta for new publication (post_id={$post->ID})");
    }
    }
    add_action('transition_post_status', 'override_onesignal_update_flag', 10, 3);

    Got sick of waiting for an update so added the above to my functions.php to stop sending notifications on update.

    I then have the checkbox for “Send notification when post is published or updated” checked and it only sends on publish.

Viewing 1 replies (of 1 total)

The topic ‘Updated posts get pushed’ is closed to new replies.