Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'notifications counter'

Viewing 25 results - 26 through 50 (of 64 total)
  • Author
    Search Results
  • #257597
    danbp
    Participant

    Don’t hack core files. (never !) Which language do you use ?

    Where have you done this ?
    I’ve took a look at the files and found out that the working ones are using __( "Foo %s", "buddypress" ) and the wrong ones are using _x( "Foo %s", "Blah blah blah", "buddypress" ).

    Actually all BP strings are working. If you need custom translation, you have to do that in po/mo and to use preferably the original strings. For example, if you build a template and want to use the notification count on it, you copy the original string to your work. If you don’t do that, you nedd 2 po/mo ! One for BP and one for your custom work. Which is certainly not the best and easiest solution.

    The notification count is defined in wp-content/plugins/buddypress/bp-notifications/classes/class-bp-notification-component.php

    The counter itself is inside a span and is defined separately.

    /* translators: %s: Unread notification count for the current user */
    _x( 'Notifications %s', 'Profile screen nav', 'buddypress' ),
    sprintf(
    	'<span class="%s">%s</span>',

    The bla bla bla part you mention is a comment for translators who indicates him the context. This comment appears in the pot file like: Notification %s [Profile screen nav]

    That’s BP’s default coding. You haven’t to modify this. Use it as is.

    If you have difficulty to translate such a string, you have to check your theme or any custom function you added (by hand or another plugin).

    The corresponding custom string should reflect the original one as gettext function wouldn’t translate a string which is not identic.

    __( "Foo %s", "buddypress" ) and _x( "Foo %s", "Blah blah blah", "buddypress" ) are both working, and do technicaly the same thing (foo = something) which let you modify “foo” in both case, but as the original string is _x( "Foo %s", "Blah blah blah", "buddypress" ), you couldn’t replace it with __( "Foo %s", "buddypress" ). It is the translation prefix (_x or __) which is the important thing here.

    Hope to be clear. And you’re right, unfortunately your changes will be overwriten at next BP update as you hacked core files.

    #255213
    m1000
    Participant

    After 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’

    berkelmudez
    Participant

    After 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-SMTP

    The plugin for me that did succeed in setting the smtp for buddypress email notifications was:
    – Postman SMTP

    I 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.

    Mike
    Participant

    I 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.

    @mcuk
    Participant

    Hi @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' to theme_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 .bubble that is different.

    Hopefully the above helps!

    Mike
    Participant

    Hi @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.

    #250459
    Mustaasam Saleem
    Participant

    This question is already answered many times.
    Please have a look. 🙂
    https://buddypress.org/support/search/notifications+counter/

    #247583
    shanebp
    Moderator

    Try:

    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' );
    #244069
    danbp
    Participant

    hi 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 😉

    #243049
    danbp
    Participant

    Yes 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 use bp_get_total_unread_messages_count( bp_loggedin_user_id() )

    Complete solution

    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;
        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 ! 😉

    #243047
    danbp
    Participant

    Add 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' );
    Osisis
    Participant

    Have 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.

    @mcuk
    Participant

    Thanks @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_count

    with

    bp_get_total_unread_messages_count or bp_friend_get_total_requests_count as needed.

    danbp
    Participant

    Two 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/

    @mcuk
    Participant

    Hi all,

    I am trying to insert a notification counter bubble within my main navigation menu after one specific ‘menu item li id’. Using the code below I have managed to display the counter correctly on the page but am unable to work out how to place it where I want after the desired menu item. Can anyone offer any pointers?

    I already have the code to display the notification counter:

    echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );

    I then added it to my theme’s child header.php within the main menu container div and gave it it’s own div & id to enable styling:

    <div id="testid"><?php echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ); ?></div>

    (Putting it here was just a test to see if the echo and CSS were correct).

    The CSS which makes it appear correctly:

    #testid {
    	background: #eee;
    	border-radius: 50%;
    	border: 1px solid #ccc;
    	color: #000;
    	display: inline;
    	font-size: 70%;
    	margin-left: 2px;
    	padding: 3px 6px;
    	text-align: center;
    	vertical-align: middle;
    }

    I ran a search for ‘notification counter’ along with a few other things but didn’t come across a recognisable solution.

    Thanks

    #235574
    danbp
    Participant

    hi @tennaki,

    did you searched a little before asking ? 😉
    This subject was handled many times in the past.
    https://buddypress.org/support/search/notifications+counter/

    #233352
    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

    #233349
    danbp
    Participant

    Try 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 );
    #233333
    danbp
    Participant

    Try 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++;
    			}	
    #231406
    danbp
    Participant

    Thxs @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,…

    #231398
    danbp
    Participant

    hi 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 ! 😉

    #230308
    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 posted

    The 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.

    #179369
    danbp
    Participant

    Hi @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.

    danbp
    Participant

    hi @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.

    #174702
    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.

Viewing 25 results - 26 through 50 (of 64 total)
Skip to toolbar