【发布时间】:2019-01-06 09:43:28
【问题描述】:
我正在 WordPress 中创建 PWA,我想使用不同类别的帖子向用户群发送通知。我已经咨询了 Onesignal guide here。 我使用帖子 WordPress 类别的 slug 基于标签创建了细分。
我安装了OneSignal插件,并按照this solution的建议。
表单可以正常工作,根据用户选择的类别将用户划分为用户。但是,当发送某个类别的帖子时,我无法发送通知,实际上在functions.php 中添加建议的代码(请参阅附件代码)不再发送任何通知。
我哪里做错了?
对于我不确定的英语,我深表歉意,我感谢那些关注我问题的人。 谢谢和问候
/**
* Send notifications based on category, Onesignal
*/
add_filter('onesignal_send_notification', 'onesignal_send_notification_filter', 10, 4);
function onesignal_send_notification_filter($fields, $new_status, $old_status, $post)
{
$categories = get_the_category($post->ID);
// Change which segment the notification goes to, will always be the first category
$fields['included_segments'] = array($categories[0]->name);
return $fields;
}
将此代码添加到我的子主题的functions.php 中,OneSignal 不会发送更多通知
【问题讨论】: