Um, yikes! I posted the wrong response in this thread. That was meant to go into another thread. Sometimes I just CANNOT multitask!!!
OK, let's see.... I keep count for two different reasons, one in forum a&b, another in forum c&d. I added two columns to the user table - ttdtrader_s and ttdtrader_v - int(10), unsigned, not null, default 0. Then created a plugin at newthread_post_complete with the following code:
PHP Code:
if (in_array($foruminfo['forumid'], array(a,b))) {
$db->query_write("UPDATE user SET ttdtrader_s = ttdtrader_s + 1 WHERE userid=" . $vbulletin->userinfo['userid']);
}
if (in_array($foruminfo['forumid'], array(c,d))) {
$db->query_write("UPDATE user SET ttdtrader_v = ttdtrader_v + 1 WHERE userid=" . $vbulletin->userinfo['userid']);
}
To initially do the count, I ran a couple of queries - I actually wrote them into a Scheduled Task so I can run it easily:
PHP Code:
$vbulletin->db->query("
UPDATE " . TABLE_PREFIX . "user
SET user.ttdtrader_s = (SELECT count(*) FROM " . TABLE_PREFIX . "thread WHERE thread.postuserid = user.userid AND forumid IN ('a','b') AND sticky=0)"
);
$vbulletin->db->query("
UPDATE " . TABLE_PREFIX . "user
SET user.ttdtrader_v = (SELECT count(*) FROM " . TABLE_PREFIX . "thread WHERE thread.postuserid = user.userid AND forumid IN ('c','d') AND sticky=0)"
);