Hi,
Which type of notifications would you like to hide? If it’s notifications created manually, posts or cpts notifications, you can use this filter hook in your theme’s functions.php file: wnbell_notification_conditions to exclude seen notifications.
If it’s user notifications, you can delete seen notifications by adding this to your theme’s functions.php:
add_action(‘wnbell_add_unseen’, ‘delete_seen_callback’,11,1);
function delete_seen_callback($notification_id){
$current_user_id = get_current_user_id();
$user_meta_field = ‘wnbell_unseen_comments’;
$unseen_array = get_user_meta($current_user_id, $user_meta_field, true);
if (!$unseen_array) {
$unseen_array=array();
}
foreach($unseen_array as $key=>$notification){
if($notification[‘type’]===’cfc’ && $notification[‘comment_id’]==$notification_id){
//unset
unset($unseen_array[$key]);
}
}
update_user_meta($current_user_id, ‘wnbell_unseen_comments’, $unseen_array);
}
This applies only to comment replies notifications, it needs slight changes for the other user notifications so let me know which type of notifications you’re using.
Hi, thanks for your reply. My question is regarding notifications created automatically from posts and custom post types and notifications created manually by adding a notification.
Thank you
Hi, in that case, you can try this in your theme’s functions.php file (or in a custom plugin):
add_filter("wnbell_notification_conditions", "add_notification_conditions");
function add_notification_conditions()
{
$condition = "";
$current_user_id = get_current_user_id();
$seen_posts = get_user_meta($current_user_id, 'wnbell_seen_notification_post', true);
if (!$seen_posts) {
return $condition;
}
$condition = "AND posts.ID NOT IN(" . wnbell_escape_array($seen_posts) . ")";
return $condition;
}