@henrywright
I tried using the below code but it is returning the value to zero too đ
echo bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
…how do I get it?
That depends. For example:
If you want the currently logged-in user:
$user_id = bp_loggedin_user_id();
If the context is a member’s profile page and you want the displayed member:
$user_id = bp_displayed_user_id();
So, depending on the above, what you need may be either:
bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
or
bp_notifications_get_unread_notification_count( bp_displayed_user_id() );
Because we’re talking about notifications, it’s likely you’ll want the former because you wouldn’t really need to show somebody else’s notifications count.
@henrywright
Thanks for the reply but
I used the below code to print the notification count on my page to match it with the notification count which is shown by wordpress and I noticed that the below code returns the value to zero no matter what ever the original notification count is.
echo bp_notifications_get_unread_notification_count( $user_id );
and yes I need unread notification count.
There’s 2 types of notifications: a) read and b) unread.
bp_notifications_get_unread_notification_count( $user_id ) will get you the unread count so you could use that value in the comparison you mentioned here.
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++;
}
Hey,
I am trying to change the page title whenever there are notifications.
If a user has more than 0 notifications then it should show, ‘You Have New Notifications’.
I have tried out this code :
$notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
$count = ! empty( $notifications ) ? count( $notifications ) : 0;
if ( $count>0 ) {
add_filter('wp_title','my_page_title',10,1);
function my_page_title($title){
$title='You Have New Notifications';
return $title;
}
}
But, it is not working. It is only working when I change the value of this code
$count = ! empty( $notifications ) ? count( $notifications ) : 0;
from 0 to 1,2 etc. Something like this,
$count = ! empty( $notifications ) ? count( $notifications ) : 2;
So, it is reading this end number as the number of notifications. I referred the notification code from here
How can I make this code work?
Thanks
Have a nice day!
We’re looking to improve the invite process for BuddyPress 2.3.
I’m going to ping @dcavins, as he will be implementing the invite improvements, so he’s aware of this.
Just to answer your questions:
Notification in the profile windowâs (there are 3 notifications: message (1) â friends (1) â but in GROUPS there is no notification).
The “Groups > No Pending Invites” nav item is for invites you have requested. Not invites that are pending for the entire group.
The user (A) has posted in a group wallâs and the user (B) has done a comment.
The user (A) hasnât received notification neither admin toolbar or administration profile windows.
Currently, notifications do not occur for activity comments. We’ll likely add this enhancement into core eventually, but for now, you’ll have to use a plugin for this:
BuddyPress Activity Comment Notifier
The user (A) has opened a forum in a grup. The user (B) has done a comment.
The user (A) has received notification in the administratio toolbar. But when the user (A) has done a comment the user (B) donât has received the notification.
How did user A reply to user B? On the group activity homepage or on the actual group forum topic? If user A replied on the group forum topic, then this sounds like an issue with bbPress, not BuddyPress.
Wordpress 4.1 and BP 2.1.1
Here is what I’m doing:
1) user clicks on a “create account” link and fills out a Gravity form and submits it.
– one of the fields is a xProfile field.
– BP puts that user in the pending state (xProfile data is not in bp_xprofile_data yet)
2) user gets an email with an activation link and clicks on it
3) user is redirected to the the successful activation page (page=gf_activation&key=421e779e1d92054f) Here, I can display the xProfile data on the page using xprofile_get_field_data.
– I have overridden wp_new_user_notification with my own function to enhance the registration email
4) email is sent to user with his username and password
My problem is that I want to include the xProfile data in the email, but it is not written to bp_xprofile_data until after the email has been sent. In fact, the wp_user is not created until after the email is sent. But the data has to be somewhere because I can access it when generating the success activation page!
Where the heck is this data stored while the new user is in the pending state and how do I access it?
@henrywright
The code is working fine. But, now the website is showing this strange behavior. Whenever I try to go to something like, example.com/username/profile or /notifications etc.
It gets me back to, example.com/username
And if I remove the code the error goes away.
Any ideas why is that happening?
Thanks
In other way, I will be using this code for the whole site except login widgets (like BBpress log in sidebar widget):
function jessicana_redirect_page( $redirect_to, $request, $user ) {
$redirect_to = bp_core_get_user_domain($user->ID) . 'notifications/';
return $redirect_to;
}
add_filter('login_redirect', 'jessicana_redirect_page', 11, 3);
For widgets, I need a different function that redirects to the same page where users logs from. Is this possible?
I appreciate the help
One more question. What if I want users who logs in using the sidebar widget to return to the same page where they were while I want users who logs in using homepage link to be directed to their notifications page?
Try this:
function jessicana_redirect_page( $redirect_to, $request, $user ) {
$redirect_to = bp_core_get_user_domain($user->ID) . 'notifications/';
return $redirect_to;
}
add_filter('login_redirect', 'jessicana_redirect_page', 11, 3);
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,…
Nice @danbp, but a couple of issues…
bp_core_get_notifications_for_user is deprecated.
Instead use bp_notifications_get_notifications_for_user( $user_id, $format = 'string' )
And I’d try using $format = 'object' so you can loop thru the results and only display those items related to that group.
Of course, this will only get notifications for a single person.
I’m not sure if there would be notifications for a group other than activity update…?
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 ! đ
Hi there,
I ma experiencing a weird issue on my site and I would appreciate any help!
I’ve installed both bbPress and BuddyPress on my site and recently I noticed that the notifications are not working correctly.
Here is what happen: If user “B” replies on user “A” comment, user “A” is getting notification only if he has started the topic. If the topic is started by user “B” or anyone else, user “A” won’t get any notification inside the site (at least email is sent to user “A” email).
Same will happen is user “A” replies to user “B” comment – he will get notification only if the topic is started by user “B”.
Anyone with the same or similar issue?
I am running the latest versions of all plugins, theme and core.
Thank you and happy holidays to all of you!
Stefan
I have an interesting situation I am hoping someone can help me with. I was tasked with merging two sites into a multi-site. The “main” site is NOT BuddyPress. The “sub” site IS BuddyPress. We merged all the users into the Network Users. I can go up to Network users and see all 8000 users there. If a user logs in on the main site, they can navigate to the subsite (i.e.: the BuddyPress) site just fine.
However, today I saw a “Pending” notification at the subsite (i.e.: the BuddyPress) site. However, when I go to the BuddyPress site and click on the Users -> Pending, I get the message “You do not have sufficient permissions to access this page.” I am an Administrator on the BuddyPress site and a SuperAdmin on the Network.
I’ve also set the define ( ‘BP_ROOT_BLOG’, 8 ); in my wp-config file.
I’ve researched all over the internet on how to set BuddyPress up as a subsite only (i.e.: not at the Network). There is confusing information out there whether this is possible or not. I am very afraid to activate BuddyPress at the Network level because we absolutely don’t want it for the “main” site.
Please, someone let me know if/how this setup is possible?
Hi there,
I’m using the following Code to show users unread messages and pending friend requests in the sidebar:
Friendship Requests
Freundschaftsanfragen: <?php echo bp_friend_total_requests_count() ?>
Unread Messages
Nachrichten: <?php bp_total_unread_messages_count() ?>
(I’m using “Enhanced Text Widget” to show php-code in my sidebar-widget)
Additionally, I want to create some kind of notification that displays users if they have new messages or requests and thtat is only shown IF there are any new messages or requests!
I imagine it should look something like:
if (unread messages > 0)
echo “You have unread Messages”;
else
echo ” “;
if (pending friendship requests > 0)
echo “You have new friendship requests”;
else
echo ” “;
my problem is, that I don’t know the names of the variables to use (I tried it with the functions instead of the variables which didn’t work). Can anyone of your pls help? I’m using the “allow PHP in posts and pages” plugin to use php in posts and pages^^
My WordPress-Version is 4.0.1, my Buddypress-Version is 2.1.1
My website is still under construction and has directory protection, which is why I won’t post the domain, username or password. If your realy need this information, I’ll send it to your via pm.
P.S. English is not my native language, I apologize for any typos or other kind of misstake.
I there,
I have noticed that when a user want to change his email address in the settings tab, a red notification appears on screen.
here a screenshot (it’s in french, sorry ^^): http://www.yungo.fr/pending.jpg
translation : “There is a pending change of your email address to %1$s.<br />Check your email (%2$s) for the verification link. Cancel”
The thing is there is no email sent to the former email address.
I’d like either send this confirmation email like it’s supposed to or remove the whole checking /confirmation process.
Any ideas ?
Thanks for further help đ
I have the following on another network:
<?php
/*
Plugin Name: BP Multi Network
Plugin URI: http://wpmututorials.com/news/new-features/multiple-buddypress-social-networks/
Description: Segregate your BP networks in a multi-network WP install (must be installed in the mu-plugins folder)
Version: 0.1.1
Author: Ron Rennick
Author URI: http://ronandandrea.com/
*/
/* Copyright: (C) 2011 Ron Rennick, All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function ra_bp_multinetwork_filter( $prefix ) {
global $wpdb;
if( $wpdb->siteid > 1 && $prefix == $wpdb->base_prefix ) {
$current_site = get_current_site();
return $wpdb->get_blog_prefix( $current_site->blog_id );
}
return $prefix;
}
add_filter( âbp_core_get_table_prefixâ, âra_bp_multinetwork_filterâ );
function ra_bp_multinetwork_meta_key_filter( $key ) {
global $wpdb;
static $user_meta_keys = array(
âlast_activityâ => false,
âbp_new_mention_countâ => false,
âbp_favorite_activitiesâ => false,
âbp_latest_updateâ => false,
âtotal_friend_countâ => false,
âtotal_group_countâ => false,
ânotification_groups_group_updatedâ => false,
ânotification_groups_membership_requestâ => false,
ânotification_membership_request_completedâ => false,
ânotification_groups_admin_promotionâ => false,
ânotification_groups_inviteâ => false,
ânotification_messages_new_messageâ => false,
ânotification_messages_new_noticeâ => false,
âclosed_noticesâ => false,
âprofile_last_updatedâ => false,
ânotification_activity_new_mentionâ => false,
ânotification_activity_new_replyâ => false
);
if( $wpdb->siteid < 2 || !isset( $user_meta_keys[$key] ) )
return $key;
if( !$user_meta_keys[$key] ) {
$current_site = get_current_site();
$user_meta_keys[$key] = $wpdb->get_blog_prefix( $current_site->blog_id ) . $key;
}
return $user_meta_keys[$key];
}
add_filter( âbp_get_user_meta_keyâ, âra_bp_multinetwork_meta_key_filterâ );
In terms of the BP Multi-Network plugin I have the following on one network:
<?php
/*
Plugin Name: BP Multi Network
Plugin URI: http://wpmututorials.com/news/new-features/multiple-buddypress-social-networks/
Description: Segregate your BP networks in a multi-network WP install (must be installed in the mu-plugins folder)
Version: 0.1
Author: Ron Rennick
Author URI: http://ronandandrea.com/
*/
/* Copyright: (C) 2011 Ron Rennick, All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function ra_bp_multinetwork_filter( $prefix ) {
global $wpdb;
if( $wpdb->siteid > 1 && $prefix == $wpdb->base_prefix ) {
$current_site = get_current_site();
return $wpdb->get_blog_prefix( $current_site->blog_id );
}
return $prefix;
}
add_filter( âbp_core_get_table_prefixâ, âra_bp_multinetwork_filterâ );
function ra_bp_multinetwork_meta_key_filter( $key ) {
global $wpdb;
static $user_meta_keys = array(
âbp_new_mention_countâ => false,
âbp_favorite_activitiesâ => false,
âbp_latest_updateâ => false,
âtotal_friend_countâ => false,
âtotal_group_countâ => false,
ânotification_groups_group_updatedâ => false,
ânotification_groups_membership_requestâ => false,
ânotification_membership_request_completedâ => false,
ânotification_groups_admin_promotionâ => false,
ânotification_groups_inviteâ => false,
ânotification_messages_new_messageâ => false,
ânotification_messages_new_noticeâ => false,
âclosed_noticesâ => false,
âprofile_last_updatedâ => false,
ânotification_activity_new_mentionâ => false,
ânotification_activity_new_replyâ => false
);
if( $wpdb->siteid < 2 || !isset( $user_meta_keys[$key] ) )
return $key;
if( !$user_meta_keys[$key] ) {
$current_site = get_current_site();
$user_meta_keys[$key] = $wpdb->get_blog_prefix( $current_site->blog_id ) . $key;
}
return $user_meta_keys[$key];
}
add_filter( âbp_get_user_meta_keyâ, âra_bp_multinetwork_meta_key_filterâ );
@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.
Hello
I run a social network website using the latest version of WordPress and BuddyPress version 2.1.1 and have no coding experience. I have a separate email for new user notifications. I was pleased that the email had over 60,000 new user registrations, but then I was shocked when I looked at the dashboard, users for the first time and saw it stated only about 12,000 subscribers but over 310,000 pending. The pending amount is increasing, while the subscribers are decreasing. I have the option to manually activate but there are too many and people are still joining.
I joined under a different email to my admin ones, but I did not get an activation email and had to manually activate.
How can I clear the backlog of pendings and make sure all future registrations are automatically activated?
Thank you
Sharon
Hey
I tried to look up in support but did not find anything for this.
I want to add a feature to my website,
1. If the user has not logged in for 30 days, a reminder is sent to him for latest activity on website
2. if the user has not completed his profile then a email is sent to him after 24 hours of creating profile.
Thanks in advance
Thanks @henrywright
Here is the list:
Admin Tweaks
Advanced Excerpt
Antispam Bee
bbPress
Bowe Codes
BP Auto Activate Autologin Redirect To Profile On Signup
Bp Clear Notifications
BP Group Activities Notifier
Broken Link Checker
BuddyBlock
BuddyPress
Buddy Press Activity Ads
BuddyPress Activity as Wire
BuddyPress Activity Comment Notifier
BuddyPress Activity Privacy
BuddyPress Block Activity Stream Types
BuddyPress Live Notification
BuddyPress Profile Visibility Manager
BuddyPress Security Check
BuddyPress Usernames Only
Delete Expired Transients
Duplicator
Email Login
Facebook Like User Activity Stream For BuddyPress
Google Analytics +
Imsanity
Infinite SEO
Insert Headers and Footers
Mailjet for WordPress
Menu Items Visibility Control
OPcache Dashboard
Post Voting
Pretty Link Lite
Query Monitor
Random Banner
rtMedia for WordPress, BuddyPress and bbPress
rtMedia Pro
s2Member Framework
SearchWP
SearchWP bbPress Integration
Social Likes
Subscribe To Comments
User Activity
Wordfence Security
WordPress FAQ Manager
WP-DBManager
WP-Memory-Usage
wp-Monalisa
WPBakery Visual Composer
WP Better Emails
WP External Links
WP Maintenance Mode
WPMU DEV Dashboard
WP Widget Cache