Notifications
Clear all

[Closed] Helpful PHP Script for Topic Review

5 Posts
4 Users
1 Likes
2,202 Views
Posts: 83
Topic starter
(@timrodman)
Estimable Member
Joined: 7 years ago

Hi Everyone,

Just wanted to share a PHP script here in case anyone else finds this useful.

My forum is growing rapidly thanks to wpForo and I was having trouble keeping up on all of the Topics using the email notifications. Some would get buried in my inbox.

So, I came up with a method to ensure that I keep up with every Topic. My rule is that, if I'm the most recent person to reply to a Topic or if I "liked" the most recent reply to a Topic, then I don't need to look at that Topic. If someone later replies to that Topic, then it needs to appear on my list of Topics to review for me to either reply to or "like" the most recent reply.

My list of Topics that I need to address is displayed using a PHP script. This is basically the queue that I work off of.

The PHP script is included below. If you want to use it, you need to replace the following:

  1. MyUser: Your database user
  2. MyPassword: Your database password
  3. MyDatabase: Your database name
  4. MyWebsite: Your website
  5. MywpForoPath: The path to your wpForo forum
  6. 5: The number 5 appears two times and it's my userid in the database (replace 5 in both places with your userid)
<html>

<?php
$mysqli = new mysqli("localhost", "MyUser", "MyPassword", "MyDatabase");
$posts = $mysqli->query("SELECT p.postid,p.created 'postcreated',pu.display_name 'postuser',t.topicid,t.created 'topiccreated',tu.display_name 'topicuser',t.title 'topictitle',CONCAT('https://www.MyWebsite.com/MywpForoPath/',f.slug,'/',t.slug) 'URL' FROM wp_tmee_wpforo_topics t JOIN wp_tmee_wpforo_posts p ON t.last_post=p.postid AND (SELECT COUNT(*) FROM wp_tmee_wpforo_likes WHERE postid=p.postid AND userid=5)=0 JOIN wp_tmee_wpforo_forums f ON t.forumid=f.forumid JOIN wp_tmee_users pu ON p.userid=pu.ID JOIN wp_tmee_users tu ON t.userid=tu.ID WHERE p.userid<>5 ORDER BY p.postid");
?>

<table border='1' cellpadding='10' cellspacing='0'>
<tr>
<th>#</th>
<th>PostID</th>
<th>Post Created</th>
<th>Post User</th>
<th>TopicID</th>
<th>Topic Created</th>
<th>Topic User</th>
<th>Topic Title</th>
<th>URL</th>
</tr>

<?php
$counter = 1;
while($row = mysqli_fetch_array($posts))
{
echo "<tr>";
echo "<td>" . $counter . "</td>";
echo "<td>" . $row['postid'] . "</td>";
echo "<td>" . $row['postcreated'] . "</td>";
echo "<td>" . $row['postuser'] . "</td>";
echo "<td>" . $row['topicid'] . "</td>";
echo "<td>" . $row['topiccreated'] . "</td>";
echo "<td>" . $row['topicuser'] . "</td>";
echo "<td>" . $row['topictitle'] . "</td>";
echo "<td><a href='".$row['URL']."' target='_blank'>click for post</a></td>";
echo "</tr>";
$counter++;
}
?>

</table>
</html>
4 Replies
2 Replies
(@central4allgmail-com)
Joined: 6 years ago

Prominent Member
Posts: 530

Your script shows all the new posts from one topic or the only the last one ?

Thank you for your time

writetoyogen
(@darjeeling)
Joined: 6 years ago

Estimable Member
Posts: 78

Thank you for taking time to write and post this PHP code. I have a question

Is this script safe to use? @timrodman @robert

Can it be added to core in future release? @robert

Robert
Posts: 10503
Admin
(@robert)
Support Team
Joined: 8 years ago

Thank you for sharing this script.

Posts: 83
Topic starter
(@timrodman)
Estimable Member
Joined: 7 years ago

It just shows the Topics (not Posts) where both of the following two things are not true:

1. Your user created the most recent Post on the Topic.

2. Your user liked the most recent Post on the Topic.