I have a script that I made that pulls the count of posts a user does on bbpress and displays it on wordpress page template. For some reason I can't get it to work. I know I need to add something to wordpress but I am not sure what. Here is the script so far.
function get_user_posts_forums1($user_id) {
global $wpdb; // I know I need to change this
$count = $bbdb->get_results("
SELECT COUNT( * ) AS total
FROM {$bbdb->posts}
WHERE poster_id = {$user_id};", object);
return $count[0]->total;
}
I have also tried:
function get_user_posts_forums1($user_id) {
define('ABSPATH', dirname(__FILE__).'/');
require_once('/home/username/public_html/hr/forums/bb-config.php');
global $wpdb;
$count = $wpdb->get_results("SELECT COUNT(*) FROM bb_posts WHERE poster_id = {$user_id} AND post_status = 0");
return $count[0]->total;
}
Still can't seem to get it to work.
On the second script I can get it to pull the total number of posts on the forum but not per user.
Posted 1 year ago
#