• Resolved nicoleadoff

    (@nicoleadoff)


    Hello, we have an blocking issue when using the filter ‘onesignal_include_post’ to add custom rules.

    Since we implement this hook, notification are sent regardless of the options checked by the user.

    The reason is pretty simple to understand, here is an extract of function send_notification_on_wp_post:

    if (has_filter('onesignal_include_post')) {
                    if (apply_filters('onesignal_include_post', $new_status, $old_status, $post)) {
                        $do_send_notification = true;
                    }
                }
    
                if ($do_send_notification) {

    As you can see, the result of the hook overrides $do_send_notification.

    Here is the easiest FIX :

    `if ($do_send_notification && has_filter(‘onesignal_include_post’)) {
    if (apply_filters(‘onesignal_include_post’, $new_status, $old_status, $post)) {
    $do_send_notification = true;
    }
    }

    if ($do_send_notification) {`

    With this fix, the hook is not called when user has not checked the notification option.

    Another FIX should be to give access to $do_send_notification variable in the filter ‘onesignal_include_post’. That way, we cat take its value into account without implements all checks already performed before the hook is called.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Blocking issue with hook “onesignal_include_post”’ is closed to new replies.