View Full Version : Display $jointime with hook?
ThreeD
08-10-2007, 10:11 AM
What code do I have to use to calculate the $jointime with a hook? I found postbit_display_start ($jointime = (TIMENOW - $this->post['joindate']) / 86400; ) but that doesn't work when I try to display the date in the showgroups template.
Opserty
08-10-2007, 10:16 AM
Try using $user['joindate'] instead of $this->post['joindate'].
ThreeD
08-10-2007, 11:07 AM
Thanks Opserty, to be honest I don't know if I implemented the hook correctly. If I want to create a hook to display a members jointime correctly in showgroups.php what hook location do I have to use? showgroups_user or something else?
Dismounted
08-10-2007, 11:17 AM
Look in the PHP file, you can then tell where you'll need to hook it.
ThreeD
08-10-2007, 11:28 AM
thanks dismounted, but I meant how do I know what the hook location has to be when I create the NEW plugin/hook? I created a new hook with the info opserty gave me,
Product: vbulletin
Hook location: showgroups_user? <- This is the one I am not sure if is correct?
title: showgroups_userjd
execution order: 5
Plugin php code: $user['joindate'] instead of $this->post['joindate']
Should the hook location be showgroups_start or is showgroups_user correct?
Opserty
08-10-2007, 11:45 AM
showgroups_user should be fine.
ThreeD
08-10-2007, 12:02 PM
Ok thanks Opserty. So I've created the hook! Should I insert the hook before the function is called in the showgroups.php file?
($hook = vBulletinHook::fetch_hook('showgroups_userjd')) ? eval($hook) : false;
Opserty
08-10-2007, 12:06 PM
A hook is a place where the plugins are attached to, i.e. where they are code is hooked to the PHP file to run. The whole point of hooks is to avoid editing the PHP files :p
Just Add a new Plugin with the hook location set to showgroups_user.
ThreeD
08-10-2007, 12:16 PM
oh hehe, ok I added the new plugin. So if I don't have to call the hook in showgroups.php or the showgroups template, how on earth does vbulletin know how to calculate the correct joindate of the staff when members visit showgroups.php?
Opserty
08-10-2007, 12:20 PM
<font face="Courier New">$user['joindate']</font> is fetched from the database for each specific user. It already does this in the PHP and the plugin just uses the data which has already been fetched.
ThreeD
08-10-2007, 12:23 PM
ahhh ok, sorry for asking silly questions - I'm not exactly a code guru :) thanks Opserty, appreciate your help. Maybe you know why all dates in showgroup show up as January 1st, 1970? hehe
Opserty
08-10-2007, 12:26 PM
Not really lol, check the PHP code I guess. I don't know a huge amount about time in PHP so I'm not much help on that front.
ThreeD
08-10-2007, 12:31 PM
hmmm the PHP code should be fine.
<strong>$vbphrase[join_date]</strong>: $userinfo[datejoined]<br><br> in the showgroups_usergroupbit
and
$jointime = (TIMENOW - $userinfo['joindate']) / 86400; // Days Joined in the showgroups_user hook/plugin.
I am lost :) thanks for your help though Opserty, you've helped me a lot.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.