Search Results for 'notifications counter'
-
AuthorSearch Results
-
June 25, 2016 at 2:48 pm #255213
In reply to: BuddyPress 2.6.0 “Espejo” is now available
m1000
ParticipantAfter upgrade the custom loop with notifications doesn’t work anymore:
if ( is_user_logged_in() ) { if ( function_exists( 'bp_is_active' ) ) { if ( $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), $format = 'string' ) ) { ?> <div class="notif-container"> <?php } if ( $notifications ) { $counter = 0; for ( $i = 0, $count = count( $notifications ); $i < $count; ++$i ) { $alt = ( 0 == $counter % 2 ) ? ' alt' : ''; ?> <div class="my-notification<?php echo $alt ?>"><?php echo $notifications[$i] ?></div> <?php $counter++; } ?> </div><!-- notif-container --> <?php } else {} } }It returns ‘Array’
April 1, 2016 at 1:47 pm #252002berkelmudez
ParticipantAfter a lot of looking it turns out basically all the SMTP plugins that I was using/testing with weren’t working. For those that might encounter the same problem, these were plugins that did not work:
– Configure SMTP
– Easy WP SMTP
– WP-Mail-SMTPThe plugin for me that did succeed in setting the smtp for buddypress email notifications was:
– Postman SMTPI don’t have any clue whatsoever why those plugins don’t work with my site and why that one did. But it’s so it’s alright I guess.
March 22, 2016 at 12:26 pm #251669Mike
ParticipantI got this working in the end… I had to change the first letter of ‘Primary’ menu to lowercase! Is there code I can add to not display ‘0’ after messages, for instance if there are no new messages, then ‘0’ is not displayed?
I’ve got another plugin for Buddypress called ‘Compliments’ which also has a notification counter, is there a way to clear the reset counter of those notifications, once a person has viewed that particular page?
Many thanks.
March 2, 2016 at 9:13 pm #250483@mcuk
ParticipantHi @mikee1001,
The code i used for inserting the bubble counters for notifications, unread messages and total friends is:
// Notification counter bubble function bptest_main_nav_notification_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 3, 0, '<li class="bubble">' . bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_notification_bubble', 10, 2 );// Unread message counter bubble function bptest_main_nav_message_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 5, 0, '<li class="bubble">' . bp_get_total_unread_messages_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_message_bubble', 10, 2 );// Total friends counter bubble // Note, 'bp_friend_get_total_requests_count' will give the total connection request count if desired function bptest_main_nav_friend_bubble( $items, $args ) { if( $args->theme_location == 'header-menu' ) { // In manage locations via WP Dash>Appearance>Menus $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3 ) ) ) { $items_array[] = substr( $items, 0, $item_pos ); $items = substr( $items, $item_pos ); } $items_array[] = $items; array_splice( $items_array, 7, 0, '<li class="bubble">' . friends_get_total_friend_count( bp_loggedin_user_id() ) . '</li>' ); // 0,0 1st position, 1,0 2nd, etc $items = implode( '', $items_array ); } return $items; } add_filter( 'wp_nav_menu_items', 'bptest_main_nav_friend_bubble', 10, 2 );In each of the above you will want to change the
theme_location == 'header-menu'totheme_location == 'INSERT YOUR HEADER MENU NAME HERE'. The name of your menu is found via your WP Dashboard > Appearance > Menus. The three functions above were inserted into bp-custom.php .The positions of the bubbles will also need changing depending on where they should be in your menu. Do that by changing the numbers on the section
array_splice( $items_array, 7, 0, '<li class="bubble">'. The comment alongside the line in the code should help you.You’ll also need some CSS for the bubbles otherwise you probably won’t see them even if they are functioning. If you hit ctrl-A to select everything on your web page, they should show up somewhere in your menu (assuming the code has been implemented correctly of course).
As you can see in the functions above all the bubbles have been given a class called “bubble”. So put in your style.css (of your child theme) something like:
#main-navigation .main-nav ul li.bubble { transform: translate(0, 50%); width: 20px; height: 20px; padding: 2px 6px; border: 1px solid #000; border-radius: 50%; margin: 0 10px 0 0; background: #fff; color: #000; font-size: 11px; }The selector (
#main-navigation .main-nav ul li.bubble) may be different on your site because it will depend on your theme etc. So use the developer tools, F12 button, on your browser to find out the correct one. It will be the bit before the.bubblethat is different.Hopefully the above helps!
March 2, 2016 at 5:57 pm #250477Mike
ParticipantHi @mcuk , I’ve added Buddypress menu items (e.g. messages, notifications etc.) in my main WordPress menu, together with WordPress menu items (e.g. home). I also want to have the notification counters next to each of the Buddypress items, but am struggling to get your solution to work for me (doesn’t help I’m not that proficient in coding)! Should I add the code above to the functions.php of my child theme, and is it only that one file I need to edit?
Many thanks.
March 2, 2016 at 12:00 pm #250459In reply to: How to set up notification counter in WordPress menu
Mustaasam Saleem
ParticipantThis question is already answered many times.
Please have a look. 🙂
https://buddypress.org/support/search/notifications+counter/December 9, 2015 at 2:29 pm #247583In reply to: Hide count – please help a PHP newbie
shanebp
ModeratorTry:
function my_counter_nav_menu($menu) { $notif_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; $friends_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'friends/'; $msg_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'messages/'; if (!is_user_logged_in()) return $menu; $notif = '<li class="notify"><a href=" ' .$friends_url. ' ">Connections <div class="friendnumber topnavcount">'.friends_get_friend_count_for_user( bp_loggedin_user_id() ) .'</div></a></li>'; if ( bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) != 0 ) $notif .= '<li class="notify"><a href=" ' .$notif_url. ' ">Notifications <div class="notifynumber topnavcount">'. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ).'</div></a></li>'; if ( bp_get_total_unread_messages_count( bp_loggedin_user_id() ) != 0 ) $notif .= '<li class="notify"><a href=" ' .$msg_url. ' ">Messages <div class="messagenumber topnavcount">'.bp_get_total_unread_messages_count( bp_loggedin_user_id() ) .'</div></a></li>'; $menu .= $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_counter_nav_menu' );September 5, 2015 at 7:29 am #244069In reply to: [Resolved] How To Get Notification Count? (Code)?
danbp
Participanthi ailyroot,
no time to sort out what you need, but see here 3 snippets using different wya to add such item to a theme main menu or custom menu, with fixed or free position… Test and take the one you need.
//fixed position function my_nav_menu_notif_counter($menu) { if (!is_user_logged_in()) return $menu; else $notif = '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' ); //choose position function my_nav_menu_positioned_notif_counter( $items, $args ) { if( $args->theme_location == 'primary' ) // only for primary menu { $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3) ) ) { $items_array[] = substr($items, 0, $item_pos); $items = substr($items, $item_pos); } $items_array[] = $items; array_splice($items_array, 0, 0, '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'); // 0,0 is first position, 1,0 is second, etc $items = implode('', $items_array); } return $items; } add_filter('wp_nav_menu_items','my_nav_menu_positioned_notif_counter', 10, 2); // depending the theme, $theme_location may vary and this one use a menu ID function my_notif_link( $items, $args ) { $theme_location = 'primary';// Theme Location slug $existing_menu_item_db_id = 6; // menu id $new_menu_item_db_id = 66; // unique id number $label = 'Notificationas '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); $url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; if ( $theme_location !== $args->theme_location ) { return $items; } $new_links = array(); if ( is_user_logged_in() ) { // only if user is logged-in, do sub-menu link $item = array( 'title' => $label, 'menu_item_parent' => $existing_menu_item_db_id, 'ID' => 'fugit', // menu name 'db_id' => $new_menu_item_db_id, 'url' => $url, 'classes' => array( 'menu-item' ) ); $new_links[] = (object) $item; // Add the new menu item to our array unset( $item ); // in case we add more items below $index = count( $items ); // integer, the order number. // Insert the new links at the appropriate place. array_splice( $items, $index, 0, $new_links ); // 0,0 is first position, 1,0 is second, etc } return $items; } add_filter( 'wp_nav_menu_objects', 'my_notif_link', 10, 2 );Happy testing 😉
August 11, 2015 at 6:41 pm #243049In reply to: [Resolved] Add Count Near Nav Menu
danbp
ParticipantYes you can, but why would you do that as all those counters are already in the user menu (on top right, under Howdy) and on each profile ? Tsssss…., but you’re the boss ! 😉
To count friends use
friends_get_friend_count_for_user( bp_loggedin_user_id() );
To count messages usebp_get_total_unread_messages_count( bp_loggedin_user_id() )
Complete solutionfunction my_counter_nav_menu($menu) { $notif_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; $friends_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'friends/'; $msg_url = bp_core_get_user_domain(bp_loggedin_user_id()) .'messages/'; if (!is_user_logged_in()) return $menu; else $notif = ' <li><a href=" ' .$notif_url. ' ">Notif ['. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .']</a></li> <li><a href=" ' .$friends_url. ' ">Friends ['. friends_get_friend_count_for_user( bp_loggedin_user_id() ) .']</a></li> <li><a href=" ' .$msg_url. ' ">Messages ['. bp_get_total_unread_messages_count( bp_loggedin_user_id() ) .']</a></li> '; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_counter_nav_menu' );Bu yardım olabilir ! 😉
August 11, 2015 at 5:51 pm #243047In reply to: [Resolved] Add Count Near Nav Menu
danbp
ParticipantAdd this to bp-custom.php and give a try ! Should show at the left of the logout button on Buddy theme nav bar
function my_nav_menu_notif_counter($menu) { $url = bp_core_get_user_domain(bp_loggedin_user_id()) .'notifications/'; // condition: user must be loggedin if (!is_user_logged_in()) return $menu; else $notif = '<li><a href=" ' .$url. ' ">Notif ['. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .']</a></li>'; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );May 27, 2015 at 3:54 am #239730Osisis
ParticipantHave you sorted this out yet? If not, if your nav has drop down capabilities you could add the menu items in the same order they are in the adminbar. For notifications, check out this post here.
May 4, 2015 at 3:49 pm #238670@mcuk
ParticipantThanks @danbp, exactly what i needed to position the counter bubbles! Both snippets worked great.
I updated the theme_location arg in the second to get it to work with my menu and added an ID to allow the CSS. Thanks again!For anyone looking to do the same with the messages and friends request counters, replace the:
bp_notifications_get_unread_notification_countwith
bp_get_total_unread_messages_countorbp_friend_get_total_requests_countas needed.May 3, 2015 at 11:12 pm #238656danbp
ParticipantTwo snippets to do this (hopefully). The first has a fixed position (latest by default), the second let’s you choose the position.
function my_nav_menu_notif_counter($menu) { if (!is_user_logged_in()) return $menu; else $notif = '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'; $menu = $menu . $notif; return $menu; } add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );See comment how to apply a position function my_nav_menu_positioned_notif_counter( $items, $args ) { if( $args->theme_location == 'primary' ) // only for primary menu { $items_array = array(); while ( false !== ( $item_pos = strpos ( $items, '<li', 3) ) ) { $items_array[] = substr($items, 0, $item_pos); $items = substr($items, $item_pos); } $items_array[] = $items; array_splice($items_array, 0, 0, '<li>Notif '. bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</li>'); // 0,0 is first position, 1,0 is second, etc $items = implode('', $items_array); } return $items; } add_filter('wp_nav_menu_items','my_nav_menu_positioned_notif_counter', 10, 2);Reference: https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
March 7, 2015 at 12:09 am #235574In reply to: Notification count in navigation menu item?
danbp
Participanthi @tennaki,
did you searched a little before asking ? 😉
This subject was handled many times in the past.
https://buddypress.org/support/search/notifications+counter/February 1, 2015 at 2:58 pm #233352In reply to: [Resolved] How To Get Notification Count? (Code)?
chatty24
Participant@danbp
I have edited the code a bit and now it is getting displayed on all the pages as I wanted but, How can I hide the modified title when the notification count is 0. By current code is below –function bpfr_add_notification_to_page_title( $title, $original_title, $sep, $seplocation ) { global $bp; if( bp_is_user() && ! bp_get_member_user_id() ) { $user_id = 'displayed: '. bp_displayed_user_id(); } else { $user_id = 'get_member_user: '. bp_get_member_user_id(); } if (bp_notifications_get_unread_notification_count( $user_id ) ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { echo $notifications[$i]; $counter++; } $title = "You Have " . bp_notifications_get_unread_notification_count() . " New Notification(s) - "; return $title; } } add_filter( 'wp_title', 'bpfr_add_notification_to_page_title', 9, 4 );Thanks
February 1, 2015 at 2:07 pm #233349In reply to: [Resolved] How To Get Notification Count? (Code)?
danbp
ParticipantTry this (tested on 2.2 RC2)
function bpfr_add_notification_to_page_title( $title, $original_title, $sep, $seplocation ) { global $bp; if( bp_is_user() && ! bp_get_member_user_id() ) { $user_id = 'displayed: '. bp_displayed_user_id(); } else { $user_id = 'get_member_user: '. bp_get_member_user_id(); } if (bp_notifications_get_unread_notification_count( $user_id ) ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { echo $notifications[$i]; $counter++; } if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) { $title .= bp_notifications_get_unread_notification_count() . " $sep "; } return $title; } } add_filter( 'bp_modify_page_title', 'bpfr_add_notification_to_page_title', 9, 4 );February 1, 2015 at 9:18 am #233333In reply to: [Resolved] How To Get Notification Count? (Code)?
danbp
ParticipantTry this
if ( $notifications = bp_notifications_get_notifications_for_user( $user_id, $format = 'string' ) ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; echo '<span ="'.$alt.'">'. $notifications[$i] .'</span>'; $counter++; }January 2, 2015 at 11:31 pm #231406In reply to: Function to check if group has notifications
danbp
ParticipantThxs @shanebp, i ignored that. 🙄
Corrected function here:
function bpfr_sidebar_notifications_menu() { global $bp; // if user is not logged, we do nothing if ( !is_user_logged_in() ) return false; // if user is group member, show him notification + count if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && $notifications = bp_notifications_get_notifications_for_user( $user_id, $format = 'string' ) ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; echo '<p ="'.$alt.'"><i class="fa fa-group"></i>'. $notifications[$i] .'</p>'; $counter++; } } }Shows anything group related to the concerned group member.
Mentions, membership request/reject, promotion,…January 2, 2015 at 5:52 pm #231398In reply to: Function to check if group has notifications
danbp
Participanthi ouegy,
Add this snippet to your child-theme functions.php and give it a try.
First function grabs the notification
Second function allows to add a hook to the template (in your case sidebar.php)
And the hook to use.function bpfr_sidebar_notifications_menu() { global $bp; // if user is not logged, we do nothing if ( !is_user_logged_in() ) return false; // if user is group member, show him notification + count if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) && $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { echo '<ul>'; $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; echo '<li ="'.$alt.'"><i class="fa fa-group"></i>'. $notifications[$i] .'</li>'; $counter++; echo '</ul>'; } } } function bpfr_xtra_group_sidebar() { // show notification only on the group sidebar if(bp_is_groups_component() ): // your content bpfr_sidebar_notifications_menu(); endif; } add_action( 'xtragroup', 'bpfr_xtra_group_sidebar' );The hook to add to sidebar.php (or any other template)
<?php do_action( 'xtragroup' ); ?>Hope this help ! 😉
December 8, 2014 at 8:52 pm #230308In reply to: Comment to Updates not triggering notification
Paul Bursnall
Participant@sebacar @mercime Hi Sebastien, from looking at replies to your Trac ticket, I think something is being lost in translation between ourselves and the devs.
To quote the official documentation :
Notifications are a central aspect of the user experience on a BuddyPress site. By default new notifications are displayed in the admin bar profile menu, right next to the navigation menus, some themes even integrate the notification counter in other places (like in the header or sidebar of a page).
Notifications are sent out to your community members as soon as one of the following things happen:
Activity
A member mentions you in an update @username”
A member replies to an update or comment you’ve postedThe activity in bold above definitely stopped triggering notifications on 3 different sites I was testing, where it had previously generated a notification (probably 4 months+ consistently). Quite simply, that notification trigger stopped working. This should not be a new feature, it was already there.
March 6, 2014 at 1:35 pm #179369In reply to: Notification count in dynamic menu
danbp
ParticipantHi @transmission,
this is not the solution, but an example for your inspiration.
The below shows how the notification counter can be moved/implemented on the toolbar./* moving the notification counter from right to left */ remove_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 ); function bpfr_notification_ontheleft() { 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 = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>'; // Add the top-level Notifications button $wp_admin_bar->add_menu( array( /*'parent' => 'top-secondary',*/ // this is the original position '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', 'bpfr_notification_ontheleft',30); /* other position # are 10, 20, 40, 50, 60, 70, 80, 90 */In your case, you also have to check this Codex page. And possibly do some research here.
February 17, 2014 at 10:05 am #178527danbp
Participanthi @pascalh,
your issue maybe related to your theme or a custom function you use.The original “notifications” string is in bp-notifications/bp-notifications-loader.php:109
Check the po file first
If you made a custom function to get the menu, check that function.Be aware that the words “notifications”, “friends” and “groups” are coming with a count and that this counter is included in the translation within a html span tag. This is technically the point who made such translation not showing in some case. Because gettext is not very compleasant with html tags… So the problem can also be the strictness of the php version on use on your server.
You can test this by writing your translation without using the span tag. (meldingen %d for example). If this ok, you’ll be fixed.
November 24, 2013 at 12:09 am #174702In reply to: Buddypress on Mobile / Hide admin access
mattg123
Participant@pjbursnall Personally I think buddypress should disable admin access anyway as most users don’t want it but that is neither here nor there. Recreating the admin bar is pretty easy, you need to know some css, html and a few bp functions to get the current users details like username etc, as for the notifications @modemlooper or @mercime posted this a while back (my apologies for not remembering which).
function bp_notification_badge() { if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id() ); if ( empty($notifications)) { echo '<li class="li-first" id="li-first-right"><a href="' . get_home_url() . '/members/' . $current_user->user_login . '"><span class="circle-zero">0</span></a><ul class="second-level" id="second-level-right"><li class="li-second"><a href="' . get_home_url() . '/members/' . $current_user->user_login . '">No new notifications!</a></li></ul></li>'; } else { echo '<ul class="second-level" id="second-level-right">'; $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $badge = count($notifications); echo '<li class="li-third">'.$notifications[$i].'</li>'; } echo '</ul>'; echo '<a href="' . get_home_url() . '/members/' . $current_user->user_login . '"><span class="circle-badge">'.$badge.'</span></a>'; } } }As for actually disabling the admin bar + backend that can be done with a plugin, plenty of them just google.
July 11, 2013 at 1:39 pm #167928In reply to: My account menu
mathieu.urstein
Participant@espellcaste
do you have some news?
I have been able to take the notifications like this :// notifications function my_bp_adminbar_notifications_menu() { global $bp; if ( !is_user_logged_in() ) return false; echo '<li id="menu-item-9991" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-9991 parent">'; // _e( 'Alerts', 'buddypress' ); if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?> <a href="#"><span id="notifs_top"><?php echo count( $notifications ) ?></span></a> <?php } echo '</a>'; echo '<ul class="sub-menu">'; if ( $notifications ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?> <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li> <?php $counter++; } } else { ?> <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'You have no new alerts.', 'buddypress' ); ?></a></li> <?php } echo '</ul>'; echo '</li>'; }June 14, 2013 at 6:39 pm #166070In reply to: [Resolved] Notifications Template
Tecca
ParticipantYou can make your own. Here’s mine as an example. You’ll need to tinker around with the CSS or code if you’d like to display them differently. What the below does is it shows a number (the amount of notifications you have) when you have one or more. It is hidden when there are none to display. Hovering over the number will display your notifications in a drop-down.
Place into bp-custom.php:
/** * Add Notification number to template */ function my_bp_adminbar_notifications_menu() { global $bp; if ( !is_user_logged_in() ) return false; echo '<div class="notices"><ul class="notices">'; _e( '', 'buddypress' ); if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?> <li class="parent"><span class="notice-badge"><?php echo count( $notifications ) ?></span> <?php } echo '</a>'; echo '<ul class="sub-menu">'; if ( $notifications ) { $counter = 0; for ( $i = 0; $i < count($notifications); $i++ ) { $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?> <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li> <?php $counter++; } } else { ?> <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'You have no new alerts.', 'buddypress' ); ?></a></li> <?php } echo '</ul></li>'; echo '</ul></div>'; }CSS:
/*-------------------------- Notification dropdown -----------------------------------*/ .notice-badge { font-weight: bold; cursor: default; background: #d33939; padding: 0 3px; border-radius: 10px } .parent.user-bar { width: 86px; text-align:left; float: right; font-weight: bold; } .notices { float: right; margin:0; line-height: 45px; z-index: 9999; } .notices a { color: #ffffff; } .notices ul, .notices { margin:0 2px 0 0; padding:0; list-style-type:none; list-style-position:outside; position:relative; } .notices ul a:link, .notices ul a:active, .notices ul a:visited { display:block; padding: 0; text-decoration:none; } .notices ul ul a:link, .notices ul ul a:active, .notices ul ul a:visited { width: 480px; display:block; padding:0 7px; text-decoration:none; } .notices ul ul a:hover { color: #0d385f; text-shadow: none; } .notices ul li { float:left; position:relative; background:none; padding:0 12px; } .notices ul li:hover { transition: all 100ms ease-in; } .notices ul ul { width: 480px; line-height: 35px; background: #ffffff; position:absolute; right: 0; top:45px; text-align:left; padding:0; display:none; border:1px solid #eeeeee; border-bottom:none; border-top:none; box-shadow:0 0 2px rgba(0, 0, 0, 0.15), 0 3px 5px rgba(0, 0, 0, 0.1); } .notices ul ul a { color:#248361; font-weight: bold; } .notices ul li ul a { float:left; } .notices ul li ul ul { left:-170px; top:2px; margin:0px; border-right:3px solid #cccccc; border-top:1px solid #eeeeee; } .notices ul li ul li { width: 480px; padding:0; margin:0; border-bottom:1px solid #eeeeee; max-width:none; list-style-type:none; text-shadow: none; } .notices ul li ul li:hover { background: #f5f5f5; } .noticesn ul li:hover ul ul, ul li:hover ul ul ul, ul li:hover ul ul ul ul { display:none; } .notices ul li:hover ul, .notices ul li li:hover ul, .notices ul li li li:hover ul, .notices ul li li li li:hover ul { display:block; } .notices ul li ul.children li { list-style-type:none; } .notices ul li ul li.current-menu-item { background:#f5f5f5; } .notices ul li ul li.current-menu-item a { color:#585858; } .notices ul li.current-menu-item span { color:#585858; } .notices ul li.parent { background-image: url(images/menu-arrow-transparent.png); background-position: center center; background-repeat: no-repeat; } .notices ul li.parent:hover { background-image: url(images/menu-arrow1.png); background-position: 14px 36px; background-repeat: no-repeat; } .notices ul li ul li.parent:hover { background-image: url(images/menu-arrow-left.png); background-position: 152px center; background-repeat: no-repeat; }Place into header.php or wherever you’d like your notifications shown:
<?php my_bp_adminbar_notifications_menu()?> -
AuthorSearch Results