bp_notifications_add_notification (数组args美元=数组()

为特定用户添加来自特定组件的通知。

描述

参数

args美元

数组(可选)描述通知的参数数组。都是可选的。

  • “user_id”
    (int)要与通知关联的用户ID。
  • “item_id”
    (int)要与通知关联的项目的ID。
  • “secondary_item_id”
    (int)要关联通知的次要项目的ID。
  • “component_name”
    (字符串)要与通知关联的组件的名称。
  • “component_action”
    (字符串)要与通知关联的操作的名称。
  • “date_notified”
    (字符串)通知的时间戳。

默认值:数组()

返回

(int | bool)成功时新创建的通知ID,失败时为false。

文件:bp-notifications / bp-notifications-functions.php

函数bp_notifications_add_notification ($ args = array ()) {$ r = bp_parse_args (args美元,阵列(user_id = > 0, ' item_id ' = > 0, ' secondary_item_id ' = > 0, component_name ' => '', ' component_action ' => '', ' date_notified ' = > bp_core_current_time(),“is_new ' = > 1, allow_duplicate”= > false,),“notifications_add_notification”);//检查现有的重复通知。如果(!$r['allow_duplicate']){//日期通知,allow_duplicate不计入//副本状态。现有美元= BP_Notifications_Notification: get(数组(' user_id ' = > $ r(“user_id”),“item_id”= > $ r(“item_id”),“secondary_item_id”= > $ r(“secondary_item_id”),“component_name”= > $ r(“component_name”),“component_action”= > $ r(“component_action”),“is_new”= > $ r(“is_new”)));如果(!Empty ($existing)){返回false;}} //设置新的通知。$notification = new BP_Notifications_Notification;通知- > user_id = $ r(“user_id”); $notification->item_id = $r['item_id']; $notification->secondary_item_id = $r['secondary_item_id']; $notification->component_name = $r['component_name']; $notification->component_action = $r['component_action']; $notification->date_notified = $r['date_notified']; $notification->is_new = $r['is_new']; // Save the new notification. return $notification->save(); }

更新日志

更新日志
版本 描述
BuddyPress 1.9.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档,联络支持,或与我们联系销售团队