0

Done a bit of searching and cant really find the answer.

Looking for idea on how I send a user an admin bar notification in BuddyPress after a certain event is actioned in a plugin I'm building?

BP Version - 1.6.4, Wordpress Version - 3.5.1

1

First you need to setup component for this:

function notifier_setup_globals() {
    global $bp, $current_blog;
    $bp->notifier = new stdClass();
    $bp->notifier->id = 'notifier';
    $bp->notifier->slug = 'notifier';
    $bp->notifier->notification_callback = 'bp_notifier_format_notifications';//this is a function which gets notifications
    $bp->active_components[$bp->notifier->id] = $bp->notifier->id;

    do_action( 'notifier_setup_globals' );
}
add_action( 'bp_setup_globals', 'notifier_setup_globals' );

To add notifications call something like this inside your action:

bp_core_add_notification( $item_id, $user_id, $component_name, $component_action, $secondary_item_id = 0, $date_notified = false, $is_new = 1 ) ;

where $component_name in this case is notifier.

for farther reading: http://demo.myndconsulting.com/documentation/notification-functions/

0

Each BuddyPress component has a bp-[groups|friends|...]-notifications.php file. Look at its functions - they are doing notifications. Search for their names in BuddyPress plugin folders - and you will find places of how to invoke them.

Not the answer you're looking for? Browse other questions tagged or ask your own question.