ADD-ON Request: Unread Comments from Posts or Comment Replies
-
I’m trying to come up with a solution for users to be notified if they have new comments on either their posts or comment replies to their own comments. I have a page that pulls and displays the unread comments but I don’t know enough about wp-discuz’s internal ajax terminology to piggyback the upvoting / downvoting of the comments.
I’d see this much like reddit’s read/unread commenting system if you’re familiar with that. There’d be two different template tags, one to display an alert through an image or text that indicates unread messages, and another to display those images.
Here’s how I’m getting user #1’s unread comments on posts:
SELECT * FROM wp_comments where comment_date > '2020-01-01 01:13:12' and comment_post_id in (select ID from {$wpdb->posts} where post_author = 1) and comment_id not in (select comment_id from <code>wp_wc_users_voted</code> WHERE user_id = 1) and user_id not in (1) and comment_parent = '0' order by comment_date descand then unread comment replies:
SELECT * FROM wp_comments where comment_date > '2020-01-01 01:13:12' and comment_parent in (select comment_id from wp_comments where user_id = 1 and comment_date > '2020-01-01 01:13:12') and comment_id not in (select comment_id from <code>wp_wc_users_voted</code> WHERE user_id = 1) order by comment_date descthe dates were just because I didn’t see the utility of getting message from over a year ago. I think what I’m doing here is hacky at best, a more perfect solution may be to add a flag somewhere that indicates if the comment has been read by the necessary user ID yet.
The topic ‘ADD-ON Request: Unread Comments from Posts or Comment Replies’ is closed to new replies.