• Resolved meir321

    (@meir321)


    Hi, I’m currently hiding visited Notifications using a custom ID and then targeting with CSS:

    #notify_visit {
      display: none;
    }

    The issue with this is, that when everything is visited the box is empty when clicked and it doesn’t display the “Empty notification box text”

    Please advise if there is a better way to do this.
    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author wpdever

    (@wpdever)

    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.

    Thread Starter meir321

    (@meir321)

    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

    Plugin Author wpdever

    (@wpdever)

    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;
    }
    Thread Starter meir321

    (@meir321)

    Thank You!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Hide Visited Notifications’ is closed to new replies.