anyone? this looks like my starting point:
Just to start building this out as a how-to:
To add a notification, you would call this function located in bp-core-notifications.php
bp-core-notifications; function bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = false, $date_notified = false )
So as a test, if you wanted to store a notification that the user had just visited the activity page, you could make up a new notification type ‘activity_viewed’ and use this code:
bp_core_add_notification('100', (int)$bp->loggedin_user->id, 'activity', 'activity_viewed');
Of course, that’s useless unless we ping the user. Next step: how do we add the little notification to the buddy bar? Any ideas?
I am really interested in this.
I did re-create the admin bar to fit my design and got rid of the default one.
Now, I want to re-produce the notifications system.
Is that what you’re trying to achive?
I still can’t figure out how to ping the user. This would be a good topic for Buddypress Gurus to think about for a FAQ or developer guide.
The best way to figure these things out is to look at how the default BP system does it~!
Look at how friendship notifications are made in bp-friends.php and bp-friends-notifications.php
1) Create a function that contains the bp_core_add_notification() and hook it into a particular BP action.
You probably did not hook your custom function to any BP action, that’s why it isn’t doing anything.
2) Format the notification.
Here, you create a new function that formats the notification. You will use the $component_action you defined in your custom function from bp_core_add_notification(). You will hook this new function into the core component’s notification function.
Look at friends_format_notifications() in bp-friends.php for more info.
3) Delete the notification.
You’ll probably want to delete the notification when someone has viewed it!
Create a function with one of the notification delete functions in bp-core-notifications.php and hook it to a BP action.
bingo. I need a step 2. It’s always step 2 I forget about!!
I will play with this. My goal is to generate a generic “skeleton notification” system that other folks can adapt.
If you stumble upon this page using BP version 1.9 you need to know that
bp_core_add_notification() is deprecated and you should use
bp_notifications_add_notification() instead, defined in