Tagged: Buddypress Notification Widget
Hello,
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 helpHi Rav,
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.
Regards
BrajeshHi 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?Hi Rav,
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?
Thank you
BrajeshHi,
Here is the code in 2 parts.Part 1:-
https://gist.github.com/sbrajesh/002257e663d7c5660e0c4be27c781c5d
This is a copy of ‘bp_notifications_get_notifications_for_user’ with 1 line change
From
$notifications = bp_get_grouped_notifications_for_user( $user_id );
to
$notifications = bd_custom_get_grouped_notifications_for_user( $user_id, $component_name );
Part 2:-
https://gist.github.com/sbrajesh/d71d88317c649333b9e456bf3ba8cf4fAs explained in
https://buddydev.com/support/forums/topic/notifications-component_name/#post-24600You will need to replace that function with ‘bd_notifications_get_notifications_for_user’ and appropriate args.
Regards
Brajesh
The topic ‘ [Resolved] notifications component_name’ is closed to new replies.