PDA

View Full Version : {vb:raw post.threads}?


Inked_Mono
03-10-2016, 12:29 AM
Does anybody know if such a thing exists? I'm looking to keep count of threads created by members in their postbit_legacy, but have tried a few variations and can't seem to find one that works.

squidsk
03-10-2016, 12:40 AM
That statistic doesn't exist in stock vb. I think a few products add it in but I don't have links.

Inked_Mono
03-10-2016, 12:44 AM
That statistic doesn't exist in stock vb. I think a few products add it in but I don't have links.

Ack, that's really unfortunate. I think there's a few plugins that might as well. Do you know, off hand, if they'd allow for such a feed to exist? I'd like to maintain the same design structure of my postbit_legacy, and being able to just have the number generated would be fantastic.

MarkFL
03-10-2016, 01:34 AM
Create the following plugin:

Product: vBulletin

Hook Location: postbit_display_complete

Title: Get the number of threads started by a user

Execution Order: 5

Plugin PHP Code:

global $db, $vbulletin;

$user_threads = $vbulletin->db->query_read("
SELECT COUNT(*) AS thread_count
FROM " . TABLE_PREFIX . "thread AS thread
where postuserid = " . $post['userid']
);

$user_thread = $db->fetch_array($user_threads);

$post['threads'] = $user_thread['thread_count'];

Plugin is Active: Yes

Click "Save".

Now, in your postbit template (whichever you use), you can use {vb:raw post.threads} to display the number of threads started by users.

Inked_Mono
03-10-2016, 04:49 AM
You're a hero, Mark, thank you. I'll give it a shot as soon as I can.
Edit: It works perfectly, thank you!

MarkFL
03-10-2016, 05:03 AM
After editing my post above, the OP reports it now works. :o

setishock
03-10-2016, 09:13 AM
I don't use legacy. Will this work in the normal mode?

Dave
03-10-2016, 12:14 PM
It shouldn't matter if you use postbit or postbit_legacy. The only difference between those templates is the HTML inside of it.