The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Total Posts under user statistics
On the user profile page, Total Posts under user statistics shows both the replies he made or the threads he started as one total count. Is there a way I can split this count into Threads and Posts and display it?
--------------- Added [DATE]1336392963[/DATE] at [TIME]1336392963[/TIME] --------------- I forgot to mention I have vB 3.8.x |
#2
|
|||
|
|||
If you create a plugin using hook location userprofile_create and this code:
Code:
if ($threads = $registry->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $userinfo[userid] AND open=1 AND visible=1")) { $this->prepared['threads'] = $threads['threads']; $this->prepared['replys'] = $userinfo['posts'] - $threads['threads']; } then you can edit any of the block templates and insert $prepared[threads] and $prepared[replys]. |
#3
|
|||
|
|||
Thanks so much! It worked like a charm!
|
#4
|
|||
|
|||
Now that I look at it again, you might want to take out "AND open=1" from the query, because that will cause it not to count closed threads which probably isn't what you want.
|
#5
|
|||
|
|||
Hi kh99,
Thanks. I need another bit of info. Can I use the same code to create another plugin for displaying this count in each post. I presume you need the postbit_display_complete hook. Please help. |
#6
|
|||
|
|||
You could - I haven't tested it but this might work.
Code:
if ($threads = $vbulletin->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $post[userid] AND visible=1")) { $post['threads'] = $threads['threads']; $post['replys'] = $post['posts'] - $threads['threads']; } But this adds one db query per displayed post. It would be better to do something like add a threads column to the user table and manage the value the same way the user post count is managed, but of course that would be more complicated. |
#7
|
|||
|
|||
I tried as you said but it gives me the following fatal error:
Fatal error: Call to a member function query_first() on a non-object in /public_html/forums/includes/class_postbit.php(294) : eval()'d code on line 56 |
#8
|
|||
|
|||
Oh yeah...you need to add
Code:
global $vbulletin; as the first line of the plugin code. |
#9
|
|||
|
|||
I added the first line but the error persists. I added $post[threads] and $post[replys] in my template. Is that a prob?
|
#10
|
|||
|
|||
OK, I tested this code and it seems to work:
Code:
global $vbulletin; if ($threads = $vbulletin->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $post[userid] AND visible=1")) { $post['threads'] = $threads['threads']; $post['replys'] = $post['posts'] - $threads['threads']; } Yes, adding $posts[threads] and $posts[replys] is what you want to do. (I guess that should really have been "replies" ). |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|