How does it work?
bbPress Pencil Unread handles differently the way forums & topics are set as read.
- For topics, the ID of each visitor having read the topic is is stored in bbppu_read_by (posts metas table) when the topic is opened. When a new reply is added, the IDs of the users having already read the topic are deleted.
- For forums, the time of each forum's last access by the user is stored in bbppu_forums_visits (users metas table) on forum visits, and compared to the forum last activity time. This means a forum will be set as "read" if the user has visited the forum page, and even if some topics inside have not been read (but they will remain listed as non read topics when displaying the forum).
It's working that way to avoid having too much database calls / data stored.
- To avoid that a forum would be set set as 'unread' after a user posts a new topic or reply; we check the forum status (if it was read or not) before posting the topic or reply. If the forum was set to read, we'll keep that !
How can I use those functions outside of the plugin ?
Have a look at the file /bbppu-template.php, which contains functions you could need.