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:
$posts = $vbulletin->db->query_first( '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 = ' . $post['userid'] . ' and p.dateline >= UNIX_TIMESTAMP(DATE_ADD(CURDATE(), INTERVAL -30 DAY))');
$newvars = array(
'poststoday' => $posts['posts_0_day']
,'posts24hours' => $posts['posts_1_day']
,'poststhisweek' => $posts['posts_7_day']
,'postspermonth' => $posts['posts_30_day']
);
vB_Template::preRegister('postbit_legacy',$newvars); // puts variable into template