PDA

View Full Version : Hooks Documentation


MrEyes
07-28-2008, 04:39 PM
Does anybody know of any documentation for the hooks within the current version of VB?

I don't mean a list of them, I need something that details exactly when these are fired and under what conditions.

Opserty
07-28-2008, 04:47 PM
<a href="http://www.vbulletin.com/docs/html/what_is_hook" target="_blank">Hook</a>

MrEyes
07-28-2008, 04:57 PM
I was looking through that set of documents and also the API docs (http://members.vbulletin.com/api/). However, unless I have missed it, neither are verbose enough.

As an example, I need to get as much information as possible regarding the paidsub_* hooks, things like under what conditions are they fired/not fired. Are they still fired when a sub is added manually via ACP etc etc etc. To go a step further paidsub_complete, what exactly defines "complete"? When the external payment system confirms payment is cleared? When the user comes back to the forum after submitting their payment details?

The problem is that it seems the only way to obtain this information is through trial and error on a test system or reading through the code base, which is all well and good however this extremely time consuming and more importantly is prone to errors as you may not consider a particular set of events/variables that may or may not cause the hook to be fired.

Just seems odd to me that there isn't a doc anywhere that has something like this:


hook_1234_abc
Fired when the foobar hits the wibble.
This will not fire if your wibble is incorrectly aligned with the flange trembler

hook_5678_xyz
Blah blah blah

Opserty
07-28-2008, 05:13 PM
Typically you just follow the PHP code that is near that hook, in which ever PHP file it is in.

So for example if you have a hook like this:

<?php
// ...
// ...
if($_REQUEST['do'] == 'savedata')
{
// ...
($hook = vBulletinHook::fetch_hook('unique_hook_id')) ? eval($hook) : false;
// ...
}
//....
?>


You then know that hook is executed when that PHP file is "saving data".

Trial and error is the only way to start really, as you get used to vBulletin you can instinctively start going to places you know where code is executed. It is always good to keep the PHP file that the hook is located in, open when you are developing plugins.