MyBB Community Forums

Full Version: check if post is unread
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is the best way to chack post status (read/unread) for guest and users
maybe exist - samoone have ready function?
For a logged in user you'll want to query the mybb_threadsread table first.
$query = $db->simple_select("threadsread", "*", "tid=$tid AND uid=" . $mybb->user['uid']);
$threaddata= $db->fetch_array($query);

Then in your while loop for posts put this:
if($post['dateline'] > $threaddata['dateline'])
{
// Post is unread.
}
else
{
// Post is already read
}

I believe for guests it stores the data as cookies.
yes that I know Smile good to look in to forumread DB table too

guest have cookie

$last_read = my_get_array_cookie("threadread", $thread['tid']);
$forum_read = my_get_array_cookie("forumread", $fid);
if(isset($mybb->cookies['mybb']['readallforums']) && !$forum_read)
	{
		$forum_read = $mybb->cookies['mybb']['lastvisit'];
	}