As promised in this post, I was finally able to upload the BBPress Analytics plugin to
WordPress plugin directory, BBPress Analytics plugin, all you have to do is copy it to the wp-content/plugins folder, see that BBPress plugin is enabled and enable the plugin.
To see the analytics of your BBPress forum, go into the BBPress analytics tab on your WordPress dashboard section, there you can find total number of topics, number of replies, replies and topics per day, unanswered topics and posts and topics per user.
Currently there is no configuration page for the plugin and all changes should be done in the code itself on the bbpressAnalytics.php file.
Behind the scenes
The code itself is fairly straight forward, you can see there is always a ‘get’ function that gets the data from the DB and a ‘show’ function that visualizes the data into the tables.
BBPress uses the wp-posts table to add it’s posts and replies and the main difference is that those are typed with the respective values. To get all the topics from the DB all that we need to do is run this query: SELECT * FROM wp_posts WHERE post_type = ‘topic’, to get the replies just replace the post_type from ‘topic’ to ‘reply’.
You can see the rest of the queries in the plugin itself and use those.
You can also add new queries by simply taking this code sample and add it to the bbpressAnalytics.php file inside the plugin.
* Your custom query
//Select 2 values to be shown on the table. (table currentlly supports 2 values)
$qry = “select value1, value2 from wp_posts where addYourLogicHere = ‘true';”;
$rows = $wpdb->get_results( $qry, ‘ARRAY_A’);
/* Shows your query on the 2 columns table.
bbpressAnalytics::printBeforeTable(“Table Name”, “Value 1″, “Value2″);
$yourQueryResults = bbpressAnalytics::getYourQuery();
$totalTopics = 0;
foreach ($yourQueryResults as $yourQueryResult)
$value1 = $topPoster[‘value1′];
$value2 = $topPoster[‘value2′];
echo “<tr><td>$value1</td><td class=”n”>’ . $value2 . ‘</td>';
Now just add: bbpressAnalytics::showYourQuery(); to the showAnalytics function.
Please comment bellow if you liked the plugin, have questions or issues using it.