Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'notifications counter'

Viewing 14 results - 51 through 64 (of 64 total)
  • Author
    Search Results
  • #167928

    In 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>';
    }
    #166070
    Tecca
    Participant

    You 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()?>

    #156809
    Shahzaib Sabir
    Participant

    @chouf1 thank you. This really works.
    Is there any idea that it works the same for the front end of the website too?
    I mean by applying the above code the counter moves at the back end bar but when visits the front end there, at bar, the counter still remains on the right side.
    I would love to listen. Again, thank you so much.

    danbpfr
    Participant

    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);

    #103479
    calvinhsu
    Participant

    @acaps2007
    What I’ve found finally:

    (It’s based on this article:
    http://easyoutsource.com/blog/how-to-code-a-custom-adminbar-in-buddypress/)

    So if you just set your adminbar to be hidden in css rather than completely disable it in the wp-config.php, you could use to call the notification menu.

    If you’ve completely disabled adminbar, then use the following code instead(it’s copied from bp-core-adminbar.php):

    <?php
    global $bp;
    
    if ( !is_user_logged_in() )
    return false;
    
    echo '<li id="bp-adminbar-notifications-menu"><a>loggedin_user->domain . '">';
    _e( 'Notifications', 'buddypress' );
    
    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    <span></span>
    <?php
    }
    
    echo '</a>';
    echo '<ul>';
    
    if ( $notifications ) {
    $counter = 0;
    for ( $i = 0; $i < count($notifications); $i++ ) {
    $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    
    <li></li>
    
    <?php $counter++;
    }
    } else { ?>
    
    <li><a href=&quot;loggedin_user->domain ?>"></a></li>
    
    <?php
    }
    
    echo '</ul>';
    echo '</li>';
    ?>
    

    And as I have found out, the js effect (what you called the “mouse over” effect) is dealt automatically by bp-themes/bp-default/_inc/global.js

    In my case, I’m building a child theme of bp-default, so I don’t have to worry about js, just copy and paste css codes from bp-themes/bp-default/_inc/css/adminbar.css and adjust selectors accordingly.

    If you are not building a child theme of bp-default, then maybe you can try search in the global.js and make some copy and past.

    Good luck !

    #103461

    In reply to: Hide General Settings

    r-a-y
    Keymaster

    Add the following to your theme’s functions.php:

    `function ray_bp_remove_settings() {
    global $bp;

    // removing the existing settings tab
    bp_core_remove_nav_item( $bp->settings->slug );
    }
    add_action( ‘init’, ‘ray_bp_remove_settings’, 0 );

    function ray_bp_readd_settings() {
    global $bp;

    // add a new settings tab to use notifications as default tab
    bp_core_new_nav_item( array( ‘name’ => __(‘Settings’, ‘buddypress’), ‘slug’ => $bp->settings->slug, ‘position’ => 100, ‘show_for_displayed_user’ => false, ‘screen_function’ => ‘bp_core_screen_notification_settings’, ‘default_subnav_slug’ => ‘notifications’ ) );

    // bug in bp_core_remove_subnav_item(), we have to hack the screen function so it displays the notifications screen when you land on /settings/
    if ( $bp->current_component == $bp->settings->slug && $bp->current_action == ‘general’ )
    add_action( ‘wp’, ‘bp_core_screen_notification_settings’, 3 );

    // add back the subnav notifications tab
    $settings_link = $bp->loggedin_user->domain . $bp->settings->slug . ‘/’;

    bp_core_new_subnav_item( array( ‘name’ => __( ‘Notifications’, ‘buddypress’ ), ‘slug’ => ‘notifications’, ‘parent_url’ => $settings_link, ‘parent_slug’ => $bp->settings->slug, ‘screen_function’ => ‘bp_core_screen_notification_settings’, ‘position’ => 20, ‘user_has_access’ => bp_is_my_profile() ) );
    }
    add_action( ‘init’, ‘ray_bp_readd_settings’ );`

    Tested lightly. Encountered a few bugs, but this will work…

    #73847
    Gianfranco
    Participant

    I tried this, doesn’t print anything neaither:

    <ul id="user-menu">
    <li><a href="<?php echo bp_loggedin_user_domain() ?>/profile/edit/">My profile</a></li>
    <li>| <a href="<?php echo bp_loggedin_user_domain() ?>/messages/">My messages</a></li>
    <li>| <a href="<?php echo bp_loggedin_user_domain() ?>/groups/">My groups</a></li>
    <li>| <a href="<?php echo bp_loggedin_user_domain() ?>/friends/">My friends</a></li>
    <li>| <a href="<?php echo bp_loggedin_user_domain() ?>/photos/">My photos</a></li>
    <li>| <a href="<?php echo bp_loggedin_user_domain() ?>/settings/">Settings</a></li>

    <?php function my_bp_adminbar_notifications_menu() {
    global $bp;

    if ( !is_user_logged_in() )
    return false;

    echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
    _e( 'Notifications', 'buddypress' );

    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    <span><?php echo count($notifications) ?></span>
    <?php
    }

    echo '</a>';
    echo '<ul>';

    if ( $notifications ) { ?>
    <?php $counter = 0; ?>
    <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
    <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    <?php $counter++; ?>
    <?php } ?>
    <?php } else { ?>
    <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
    <?php
    }

    echo '</ul>';
    echo '</li>';
    }
    ?>

    <?php if( function_exists('my_bp_adminbar_notifications_menu') ) my_bp_adminbar_notifications_menu(); ?>

    </ul>

    Is anything in there correct?

    #73834
    Gianfranco
    Participant

    @r-a-y I tried this:

    <?php function my_bp_adminbar_notifications_menu() {
    global $bp;

    if ( !is_user_logged_in() )
    return false;

    echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
    _e( 'Notifications', 'buddypress' );

    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    <span><?php echo count($notifications) ?></span>
    <?php
    }

    echo '</a>';
    echo '<ul>';

    if ( $notifications ) { ?>
    <?php $counter = 0; ?>
    <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
    <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    <?php $counter++; ?>
    <?php } ?>
    <?php } else { ?>
    <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
    <?php
    }

    echo '</ul>';
    echo '</li>';
    }
    ?>

    Which is the same funtion except for the name “my_bp_adminbar_notifications_menu”.

    It doesn’t print anything.

    Probably something with the “bp_core_get_notifications_for_user” that is desabled because of my desabling the default Admin bar?

    I admit that I php is not my strong point at all.

    #73421
    r-a-y
    Keymaster

    Fixed in the 1.2 branch – courtesy Andy:

    https://trac.buddypress.org/changeset/2921

    [EDIT]

    For friend requests… haven’t encountered the other issues above yet.

    stwc
    Participant

    I’ve run in to this with importing a userbase to a Buddypress install. WordPress likes login names to be lowercase, with no spaces, and no non-alphanumerics (except, I think for dashes (‘-‘).

    Users can, of course, make their display name anything they like.

    The follow-on problem though, is with @username notifications in BP1.2+, which work on the login name and not the display name, so if a user has the login username johnsmith and the display name John, only @johnsmith will work.

    (I’ve also just recently encountered a problem in that usernames with dashes cause @notifications to fail. That is, if a username is johnsmith, @johnsmith works, but if his username is john-smith @john-smith fails.)

    #70457
    Mike Pratt
    Participant

    @LwEEs

    You can also place this code anywhere you want and style your own little Notifications Block:

    <!-- Notifications block -->
    <?php
    echo '<li id="notifications-menu"><span id="menu-title">
    <a href="' . $bp->loggedin_user->domain . '">';
    _e( 'Notifications', 'buddypress' );

    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    <span><?php echo '('.count($notifications).')' ?></span>
    <?php
    }
    echo '</a></span>';
    echo '<ul>';

    if ( $notifications ) { ?>
    <?php $counter = 0; ?>
    <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
    <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
    <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    <?php $counter++; ?>
    <?php } ?>
    <?php } else { ?>
    <li><a href="<?php echo $bp->loggedin_user->domain ?>">
    <?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
    <?php
    }
    echo '</ul>';
    echo '</li>';
    ?>

    #60124
    kineda
    Participant

    Thanks. That clears things up. The only other problem I’ve encountered is after I deactivate the BuddyPress plugin and re-activate it, I’ll get the follow db errors:

    WordPress database error: [Duplicate key name ‘useritem’]

    ALTER TABLE wp_bp_notifications ADD KEY useritem (user_id, is_new)

    WordPress database error: [Table ‘wp_bp_activity’ already exists]

    RENAME TABLE wp_bp_activity_user_activity_cached TO wp_bp_activity

    WordPress database error: [Duplicate entry ‘1’ for key 1]

    INSERT INTO wp_bp_xprofile_groups VALUES ( 1, ‘Base’, ”, 0 );

    WordPress database error: [Duplicate entry ‘1’ for key 1]

    INSERT INTO wp_bp_xprofile_fields ( id, group_id, parent_id, type, name, is_required, can_delete ) VALUES ( 1, 1, 0, ‘textbox’, ‘Name’, 1, 0 );

    #51652
    r-a-y
    Keymaster

    Just experienced the OP’s problem.

    I looked into it and found a tentative fix… though a BP dev will need to look at the code.

    In “bp-core/bp-core-notifications.php”, look for the bp_core_notifications_for_user() function.

    Then look for these lines:

    $item_id = ( 1 == $action_item_count ) ? $component_action_items[0]->item_id : false;
    $secondary_item_id = ( 1 == $action_item_count ) ? $component_action_items[0]->secondary_item_id : false;

    Change this to:

    $item_id = $component_action_items[0]->item_id;
    $secondary_item_id = $component_action_items[0]->secondary_item_id;

    I don’t know why there was a check done for only 1 item and then returning false for more than 1… if a BP dev can explain why, that’d be great.

    Let me know if anyone encounters any problems.

    Trac ticket made.

    #36748

    In reply to: Forum notifications

    fishbowl81
    Participant

    @gpo1

    Due to all communication of buddypress and bbpress being done over xmlrpc, the normal plugins most likely won’t work. I have been looking at ones like a view counter and they require massive modification of buddypress. Because of caching, the forums are not always pulled from bbpress. So it would produce falsely low view count.

    Also, group forums, are just a single forum in bbpress, this changes the administration and moderation of the forums and topics. If someone is a moderator on bbpress, they can moderate the whole site I believe, with buddypress a moderator is only a moderator of that group forum.

    Hope this helps,

    Brad

Viewing 14 results - 51 through 64 (of 64 total)
Skip to toolbar