i am new here i am developing a plugin for WordPress and i need some help from you :) i want to add custom notification to Buddypress and this is how it works: when i add a product by woocommerce , a notification appear for users .i read so many article but i don't understand what i have to do. please tell me what exactly i have to do. i read this articles but nothing ! https://codex.buddypress.org/developer/function-examples/bp_notifications_add_notification/ http://androoha.com/web-design-tuts/80-custom-notifications-buddypress-en thank you for your attention
Add bp_notification on save_post action hook whenever woocommerce product has added
You can loop over bp_notifications_add_notification function to send nonfiction to multiple users
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 );