How to implement user notifications to template without admin bar
-
How to implement user notifications to template without admin bar?
I am using custom theme and I have disabled wordpress/buddypress admin bar, that means users does not have any notifications. How to create notifications in my own theme?
-
bump
You may want to contact @modemlooper and request that he add this functionality to his awesome “Profile Menu Plugin” on its next iteration. I would love to finally have freedom of buddypress independent of this bar that sends a red flag that it’s using buddypress. The only way to do this is to get rid of this bar and implement it in the normal menu. @modemlooper I would like to request a way to add an order to your plugin, just as as you can order a custom menu. It would also be cool to have admin options to rename this extra tab to name it something other than “Profile!” Thanks!
@davidkooo – BuddyPress adds the notification bar using the function bp_members_admin_bar_notifications_menu() (in buddypress/bp-members/bp-members-adminbar.php).
If you take a look at that function, you can see how it generates the menu, and rework to include it in your template file.
In particular – take a look at the function it uses: bp_core_get_notifications_for_user()
@davidkooo, Exactly what i did, you can use “ to show notification when you have notification.
@Roger Coathup: how to edit this to work without admin bar? I know I need to replace $wp_admin_bar, but with what? I want to append it to my header, which is `
`
`/**
* Build the “Notifications” dropdown
*
* @package Buddypress
* @since BuddyPress (1.5)
*/
function bp_members_admin_bar_notifications_menu2() {
global $wp_admin_bar;if ( !is_user_logged_in() )
return false;$notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), ‘object’ );
$count = !empty( $notifications ) ? count( $notifications ) : 0;
$alert_class = (int) $count > 0 ? ‘pending-count alert’ : ‘count no-alert’;
$menu_title = ‘‘ . $count . ‘‘;// Add the top-level Notifications button
$wp_admin_bar->add_menu( array(
‘parent’ => ‘top-secondary’,
‘id’ => ‘bp-notifications’,
‘title’ => $menu_title,
‘href’ => bp_loggedin_user_domain(),
) );if ( !empty( $notifications ) ) {
foreach ( (array) $notifications as $notification ) {
$wp_admin_bar->add_menu( array(
‘parent’ => ‘bp-notifications’,
‘id’ => ‘notification-‘ . $notification->id,
‘title’ => $notification->content,
‘href’ => $notification->href
) );
}
} else {
$wp_admin_bar->add_menu( array(
‘parent’ => ‘bp-notifications’,
‘id’ => ‘no-notifications’,
‘title’ => __( ‘No new notifications’, ‘buddypress’ ),
‘href’ => bp_loggedin_user_domain()
) );
}return;
}
add_action( ‘admin_bar_menu’, ‘bp_members_admin_bar_notifications_menu2’, 90 );`@davidkooo, the code i gave you above work like a charm, i dont use admin bar i code a custom one in my header.
You can see it in action here : http://goo.gl/4OqMP
Am still working on the site.
userame : demo
password :demo@naijaping yeah it works, but how to get rid of “Notifications” text… I would like to display only number. Thanks.
@davidkooo, you can easily achieve that with css by replacing “notification text” witth image icon like facebook and only the number of notification will show on the image.
somthing like: {background:url(_inc/images/alerts-icon.png)center no-repeat transparent !important;text-indent: -9999px;width:147px;height:25px;}
Note: you have to adjust accordingly.
not bad idea
@naijaping I checked out your site and it works great. I would like to implement this as well. Would you please elaborate how this is done, and specifically which files need to be edited. Thanks!
@naijaping hey man thats works great – I dont supposed you can share the code you use to get that menu in your header.
Thanks
@naijaping @designnz +1!
@naijaping can you please tell me how to make it so that when you put your mouse on the notification button, a list of notifications/(or no notifications) come down, like in your example?
@naijaping i must admit im blown away with your customisations on that link, how have you done it i would love to see some tutorials as ive been failing with buddypress since i installed it
heres what im trying to change so any help would be awesome
– Buddypress links ie profile settings etc on my own toolbar
– 100×100 user avatar on my header which when clicked goes to users profile page
– Fix spacing problems on buddypress members menu
– On profile & group pages i would like to add a widget space on the right hand side of the avatar and recent update message
– I use custom post types i. reviews, videos and articles i would love to add these on the profile page menu so it shows what they have been the author of
– i would also love to allow each group to have a about page with an option to add thier own facebook,twitter,google+1,YouTube and Email stuff to show up as default iconsI now its kinda cheeky but any help would be truely amazing, also what plugins do you use with buddypress, im gonna go now an try and add this notifications code
“
erm does this need adding via a css style sheet or can it be done via wordpress menu page
@shawn38, @designnz, @yeshourun, i am so so sorry, have not been checking this thread as i receive no notification at all. i will share this code when am back next week. I have been working on my Main site : http://goo.gl/4OqMP
username : demo
password : demoI think i should be able to share how to make the notification work something similar to facebook.
once again apology
@naijaping Actually I have it worked out already and styled in a drop down menu on my site.
Hi all, as promised i will share the code this weekend as am a little bit busy, i have the custom notification menu working for message – general notifications and Friends request.
I.e friend request notification show up on friend icon
message notification show up on message iconand general notification on general icon.
something similar to facebook
you can see it in action
username : demo
password : demo@naijaping On second thought I do like what I see in your approach better than the drop down menu I have. So I am interest in the code. From what I can tell it seems like you have everything in in your header.php file. I would like to do this with maybe a few changes in styling. Let me know when you have the code here. Thanks!
Edit:
It would also be helpful if you can share where in the header.php file that the code needs to be placed. Thanks again!@naijaping Great work! Could you just paste the code of this nice notification plugin?
Dear Guys,
As far as I can understand from the previous post I would have the same question as the topic starter.
I would like to move the whole buddypress toolbar from the admin menu to the top nav as the picture shows below.
Could somebody help me how to achive it?
Thank you for advance!
Hi, that is just what I (and think a lot of us) need. Nothing yet about the widget code?
P.S: In this moment I’m using BuddyBar widget (https://wordpress.org/extend/plugins/buddybar-widget/) plugin is not as good as @naijaping code but do its job. A god thing about this plugin is than give You a Log in form and after log in, it changes to something like @naijaping widget.
@naturalworldstm thank you for the tip.
It would be good if @naijaping could help us with the code 😛 I’d appreciate the help.
here is a function I use: https://gist.github.com/modemlooper/5042788
to use place `<?php  bp_notification_badge() ?>` in your html. You will need to style it as well.
@modemlooper I am interested in using this too! Just for clarification would you place the function in the link you provided https://gist.github.com/modemlooper/5042788 in functions.php in my child theme then edit the header.php and then add as a li item in the menu or somewhere else in the header.php? Then style it in the style.css. Thank you!
- The topic ‘How to implement user notifications to template without admin bar’ is closed to new replies.