2014-10-26 85 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