OneSignal / OneSignal-WordPress-Plugin

OneSignal is a free push notification service for web and mobile apps. This plugin makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
80 stars 42 forks source link

notifications on specific page #281

Closed steflp closed 3 years ago

steflp commented 3 years ago

Hello, I want to push notification on specific page ( type_post=> page) . I want to use this code (from documentation) :

`add_filter('onesignal_include_post', 'onesignal_include_post_filter', 10, 3); function onesignal_include_post_filter($new_status, $old_status, $post) {

if ($post->post_type == "page"  && $new_status == "publish") {
    return true;
}

}`

But It doesnt work !

So I try to use this code but with post :

add_filter('onesignal_include_post', 'onesignal_include_post_filter', 10, 3); function onesignal_include_post_filter($new_status, $old_status, $post) { $postid = get_the_ID(); if ($post->post_type == "post" && ($postid == "15823" || $postid == "15828") && $new_status == "publish") { return true; } }

I just change post_type "page" to "post" and filter to the specific ID ($postid) And this code works well ...

iAmWillShepherd commented 3 years ago

I just change post_type "page" to "post" and filter to the specific ID ($postid) And this code works well ...

@steflp

I'm glad you've managed to get this working! I'm going to go ahead and close this issue. If you have any additional problems with the SDK, feel free to open an issue here explaining the problem and provide reproduction steps if possible.

steflp commented 3 years ago

But perhaps I found ONE solution but i dont find THE solution ! Why When i try with this code '$post->post_type == "page"' your plugin / your hook doesnt work ? And you must not close this topic , sorry ;-( ....