The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Posts Per Month
I'm looking for a plugin that will give the post count for the last 30 days... I found a couple for 3.x, but they don't work. Has anyone done one for 4.x -or- can anyone modify this one to work?
Code:
$jointime = (TIMENOW - $vbulletin->userinfo['joindate']) / 2419200; //its for a month if you can change to 604800 seconds for 1 week, 84600 for 1 day. if ($jointime < 1) // if they join time is less then 1 day { $postspermonth = vb_number_format($vbulletin->userinfo['posts']); put their current post } else { $postspermonth = vb_number_format($vbulletin->userinfo['posts'] / $jointime, 2); // more than 1 day.. } vB_Template::preRegister('memberinfo_block_statistics',array('postspermonth' => $postspermonth)); // puts variable into template hook |
#2
|
|||
|
|||
What you posted is 'average posts per month' not posts count for the past 30 days.
Hook: member_execute_start PHP Code:
PHP Code:
|
#3
|
|||
|
|||
Was looking for something similar and thanks Eosian for trying to help.
I tried out you second suggestion "the fancier" once but got an error. Database error in vBulletin 4.2.0: Code:
Invalid SQL: select sum(if( p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL 0 DAY)), 1, 0)) posts_0_day,sum(if( p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -1 DAY)), 1, 0)) posts_1_day,sum(if( p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -7 DAY)), 1, 0)) posts_7_day ,count(*) posts_30_day from post p where p.userid = and p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -30 DAY)); MySQL Error : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -30 DAY))' at line 1 Error Number : 1064 |
#4
|
|||
|
|||
$userinfo['userid'] isn't populating from where you're calling it.
What hook did you set it on? |
#5
|
|||
|
|||
Quote:
I did put the query in a module php file for vBadvanced (already have a stats.php module file) and just rendered the variables and used them in a template. Guess being a novice that was the wrong way to do it or at least the query was not intended to be used in a php file. |
#6
|
|||
|
|||
In order to port the code somewhere else you have to supply it a way of identifying the user you want information about. The $userinfo['userid'] needs to be replaced with whatever local variable has the user id of the person your module is referring to.
If it's a page you can only see about yourself it's easy; $vbulletin->userinfo['userid'] is generally globally available as a reference to 'me'. But for any page about someone else you should have some identifier for that person you can use. (Unrelated to fixing your issue, but none of what I posted was a template hook, that was a standard plugin that registers additional variables to an existing template before it renders by adding additional code to a specific event hook. A template hook is a somewhat different beast) You could actually use it in your postbit legacy just by changing the hook used. ( showthread_postbit_create and $post['userid'] and register postbit_legacy as the modified template ): PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|