MyBB Community Forums

Full Version: Who-read-what
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I asked this question in one of my previous posts, but back then I was evaluating MyBB and I was asking the same question on many forums, so I'd like to ask it again in a more focused way.

We need to know who read what thread and when so we can send out reminders to those who haven't read them.

Is this information available?

It would be nice to have all history: all posts, all views.

Also, if available, can this info be queried over http? For example, have

http://192.168.1.5/mybb/showthreadHistory.php?tid=1

return that data.

Many thanks in advance again!

Pahidla
MyBB stores threads that people read in the database to ensure they're marked as read or unread across multiple machines without relying on cookie tracking.

However, threads stored there are not stored there permanently, only up until the thread marking age specified in the Admin CP. After that, they're automatically marked as read and the marking removed from the database.

If you wish to show which users have viewed a certain thread, the basics of it would be querying the mybb_threadsread table for threads with a specific tid.

For example,

SELECT * FROM mybb_threadsread WHERE tid='1';

Or as a simple PHP script which would work with MyB:
<?php
require "./global.php";

echo "<ul>";
$query = $db->query("SELECT r.*, u.username FROM ".TABLE_PREFIX."threadsread r INNER JOIN ".TABLE_PREFIX."users u ON (u.uid=r.uid) WHERE r.tid='".intval($mybb->input['tid'])."'");
while($reader = $db->fetch_array($query))
{
	echo "<li><a href=\"member.php?action=profile&uid={$reader['uid']}\">{$reader['username']}</a></li>\n";
}
echo "</ul>";
?>

Of course, that only makes a list and doesn't use the template system or theme system at all, but it is just a basic example.

Chris