Is there anyone who knows how to get this done? @naijaping did it on his BP site and I want to do the same please! What is the best course of action to accomplish this?
Hi,
Have a look at this function
bp_core_get_notifications_for_user here https://github.com/buddypress/trunk/blob/master/bp-members/bp-members-notifications.php#L83
You can modify it to suit your need(this is the one that generates the notfication messages).
and here you can see how the drop down is created
https://github.com/buddypress/trunk/blob/master/bp-members/bp-members-buddybar.php#L18
Hope that helps.
@sbrajesh Could you create a plugin that would do this and hook into the header in bp-default because your more qualified than me because I am kinda a noob? Thank you!
Do you want it to be hooked to the main menu of the bp-default theme when a user is logged in ?
@sbrajesh That would be nice if you could do it, and make it dynamic for each users notifications. You will be my hero if this can be done. Thank you!
@sbrajesh Any news on this? Thanks a million!
@sbrajesh actually I would like to get it like facebooks notifications somewhere in the header using similar icons to dispay friend requests, messages, notifications and when you have anything then the icon will display accordingly just like facebooks. If anyone can offer assistance I would appreciate it.
@mercime Thanks but that is not going to accomplish what I am attempting to do. I can’t find anything in the codex that explains how this would be done either. The codex helped me figured out a lot of stuff about customizing BP but there doesn’t seem to be any documentation about notifications in the codex or on google. Is there anyone you can direct me too that could explain how I can get this done or better yet add some documentation to the codex regarding notifications? I would be very grateful to anyone that can help me resolve this. Thanks for your help!
@sbrajesh @mercime @naijaping
This is a rough draft of what I would like to do. All icons functional, and only appearing in header after the user is logged in. I hope this will help explain what I am doing. Thanks everyone!
Is there any BP Professionals who can help me on this? I surely would appreciate it! Thanks a million!
@bphelp,
i’m not sure of what you exactly want, but here’s something who gives you a header menu based on text links who leading to the expected member part. The example given here works on bp-default 1.6.4 (may also work on previous versions)
What to do ?
add an action call in your theme’s header.php
add a function in your theme functions.php
in header.php, after the h1 closing tag, add
<?php do_action ( 'my_header_menu_bar' );?>
add this function to your theme functions.php
function my_header_menu () {
if ( is_user_logged_in() ) { ?>
<div style="display:inline; width: 200px;float:left; ">
<a href="<?php echo bp_loggedin_user_domain() . bp_get_friends_slug(); ?>/requests/">Friends request</a>
<a href="<?php echo bp_loggedin_user_domain() . bp_get_messages_slug(); ?>/view/">Messages</a>
<a href="<?php echo bp_loggedin_user_domain() . bp_get_messages_slug(); ?>/notices/">Notices</a>
</div>
<?php
}
}
add_action ( 'my_header_menu_bar', 'my_header_menu' );
This is a rought example. You can now add img tag to replace the text in each a tag and play with css to style the div contained in the function (actually containing inline style). If you give it a class name, you can add the style to your theme style file.
@chouf1 Hey thanks for your help. Is there anyway to get the number of these individual types of notifications you have beside the links or image kinda like it does in the toolbar? Cheers!
@chouf1 Also what about creating a dropdown menu? Thanks again!
Hi not sure if this is what you are trying to do, if you go to http://smeak.com you can see it at work, we split the notifications intro 3, and into a custom toolbar we built for the network. Let me know to see if we can help
@maddogmcewan That looks great. I will accept any help you can share. Thanks! 🙂
here’re the 3 counter. Their names are explicit enough i guess to see the right place where to use 😉
echo bp_friend_get_total_requests_count( $user_id );
echo bp_get_total_unread_messages_count($name );
echo count($notifications);
@chouf1 with your help and hnla’s I have this working but even with the above examples in how to get the counts in a drop down I am not certain how to do this. Where do I place:
echo bp_friend_get_total_requests_count( $user_id );
echo bp_get_total_unread_messages_count($name );
echo count($notifications);
In the code because it either fires off an error or it actually echo’s the code. What am I doing wrong? Thanks again for all your help! 🙂
`
function custom_toolbar($wp_toolbar) {
global $wp_admin_bar;
if ( is_user_logged_in() ) {
$wp_toolbar->add_node(array(
‘id’ => ‘bp-notifications’,
‘title’ => __(‘ ‘),
‘href’ => bp_loggedin_user_domain() . bp_get_messages_slug() . ‘/notices/’,
/*’meta’ => array(‘class’ => ‘notifications’)*/
));
$wp_toolbar->add_node(array(
‘id’ => ‘user-friends’,
‘title’ => __(‘ ‘),
‘href’ => bp_loggedin_user_domain() . bp_get_friends_slug() . ‘/requests/’,
/*’meta’ => array(‘class’ => ‘menupop’)*/
) );
$wp_toolbar->add_node(array(
‘id’ => ‘user-messages’,
‘title’ => __(‘ ‘),
‘href’ => bp_loggedin_user_domain() . bp_get_messages_slug() . ‘/view/’,
/*’meta’ => array(‘class’ => ‘menupop’)*/
) );
}
}
add_action(‘admin_bar_menu’, ‘custom_toolbar’, 999);
`
Hi @chouf1, just wondering if you could help me a little more with the above code. I don’t mean to bump this but with people not getting there @mentions notifications here I am afraid it will be overlooked. Thank you kindly!
i have already helped you here for the same question: https://buddypress.org/support/topic/how-to-add-images-to-a-custom-toolbar/#post-156520
Let me tell you that you don’t ask for help now, but search somebody doing that plugin at your place. 👿
Go to the job board and hire a dev, if you don’t know go further with all the elements you already received. I’m not at your personal service !
@chouf1 No need in being nasty about it. I just thought you didn’t mind helping me since you had helped me before. I’m sorry! Anyway thanks for the other help you given it is appreciated.
🙂
Is there anyone else that would not mind helping me out on this? Thank you everyone! 🙂
I still would appreciate some help on this! Thanks everyone! 🙂
Anyone who can help? Thanks!
Just for clarification I decided to keep the toolbar and attempt to add the split up notifications to it. I just need help with display of the individual notifications in the drop-down menu.