2014-10-26 84 views
0

我在这里新建一个WordPress插件,我需要您的一些帮助:)我想向Buddypress添加自定义通知,这是它的工作原理:当我添加产品通过woocommerce,通知出现给用户。我读了这么多文章,但我不明白我必须做什么。请告诉我我到底需要做什么。我阅读这篇文章,但没有什么! https://codex.buddypress.org/developer/function-examples/bp_notifications_add_notification/http://androoha.com/web-design-tuts/80-custom-notifications-buddypress-en感谢您的关注添加与woocommerce相关的buddypress的自定义通知

+0

有任何人都可以帮我? – 2014-10-28 06:01:08

回答

0

添加bp_notification上save_post行动挂钩每当woocommerce产品已加入

您可以遍历bp_notifications_add_notification函数发送散文给多个用户

function product_add_notification($post_id, $post, $update) { 
     $slug = 'product'; 

     if ($slug != $post->post_type) { 
      return; 
     } 
     // $invited_user_id would be user_id to whom we are sending notification 
     bp_notifications_add_notification(array(
      'user_id'   => $invited_user_id, 
      'item_id'   => $post_id, 
    )); 
    } 
    add_action('save_post', 'product_add_notification', 10, 3); 
+0

@mohammad_hasani如果有帮助,请接受这个答案。 – 2014-12-08 12:43:10