Tagged: Buddypress Notification Widget
I need help. If I ask in the wrong place, I am sorry for that
I was looking for help on the internet and on the support page. Unfortunately, nobody helped me. I hope it will be different here.
I mean BuddyPress Notification Widget.
I would like the plugin to show only selected notifications with the specified ‘component_name’.
The ‘component_name’ value is specified when creating the notification and I want to refer to it to check if the notification has the value I need and then show the notification in the widget.
How to do it? please help
Welcome to BuddyDev forums.
At the moment, BuddyPress does not provide an API to find component specific notifications for user.
The notification widget is unable to do it. It is still possible to modify the code and use it fopr your purpose
You will need to change this line
With the code to fetch notifications based on component for the user.
Hi Brajesh Singh,
Thank you for your answer. Unfortunately, I don’t know how to solve the problem and how to change this code.
I know that bp_notifications_get_notifications_for_user () allows you to receive notifications for the user, but how to make a notification only from a group?
Maybe trying to refer to “component_name” and comparing whether the condition is met is a bad way, but I have no other idea. Is there any way?
The problem in this case is you need to rewrite whole the notification fetching/parsing.
It is not a difficult task as you be only modifying the code from the function ‘bp_notifications_get_notifications_for_user’, It is not much use.
I can share the modified code but I won’t be rewriting the plugin to use that code. Please let me know if you will be able to work from that?
Here is the code in 2 parts.
This is a copy of ‘bp_notifications_get_notifications_for_user’ with 1 line change
$notifications = bp_get_grouped_notifications_for_user( $user_id );
$notifications = bd_custom_get_grouped_notifications_for_user( $user_id, $component_name );
You will need to replace that function with ‘bd_notifications_get_notifications_for_user’ and appropriate args.
The topic ‘ [Resolved] notifications component_name’ is closed to new replies.