Tagged: limit message notifications
Hi Brajesh,
I require your assistance with one more issue. I use your private message rate limiter plugin and it works great. However, I am trying to design that if you have an unread message notification from one user, you will not receive anymore message notifications from that user until the notification is marked read. This is to prevent spamming. As it can be pretty annoying if you receive a message for every reply to a thread.
This is what I have so far but it doesn’t work. What can you suggest?
function limit_message_notifications ( $message ){
if ( bp_is_active( ‘notifications’ ) ) {
global $thread_template;// Get unread PM notifications for the user.
$new_pm_notifications = BP_Notifications_Notification::get( array(
‘user_id’ => bp_loggedin_user_id(),
‘component_name’ => buddypress()->messages->id,
‘component_action’ => ‘new_message’,
‘secondary_item_id’ => $message->sender_id,
‘is_new’ => 1,
) );
if (!$new_pm_notifications){foreach ( (array) $message->recipients as $recipient ) {
bp_notifications_add_notification( array(
‘user_id’ => $recipient->user_id,
‘item_id’ => $message->id,
‘secondary_item_id’ => $message->sender_id,
‘component_name’ => buddypress()->messages->id,
‘component_action’ => ‘new_message’,
‘date_notified’ => bp_core_current_time(),
‘is_new’ => 1,
) );
}
}
else{
return false;
}}
}
add_action( ‘messages_message_sent’, ‘limit_message_notifications’, 99 );Hi David,
My apologies for the delayed reply.Please let me know if I am understanding it correctly:-
1. User A has sent User B a Message first time. There gets a new notification created
2. User A sends another message(or reply) to User B. Now, if there is a previous unread message from user A, There should not be a new notification added? Is that you want?Also, do you want to prevent local notification or the email notification too?
Thank you
Brajesh
You must be logged in to reply to this topic.