Quote:
Originally Posted by rmd1
I started by finding out which hooks I need to work with, but already came across a problem.. where/how can I find out, which variables are already set, inside hook XYZ?
|
I don't think there's really any way except to read the source code. At least that's what I do. I have all the vbulletin files on my local computer set up so I can search them. I use something called NetBeans, but it's probably overkill unless you want a full development environment for other purposes. There's something called notepad++ that I think does everything you need. In any case, both are free.
Anyway, you could answer your question by searching the files for postdata_start, and you'd find this, in includes/class_dm_threapost.php:
Code:
function vB_DataManager_Post(&$registry, $errtype = ERRTYPE_STANDARD)
{
parent::vB_DataManager_ThreadPost($registry, $errtype);
($hook = vBulletinHook::fetch_hook('postdata_start')) ? eval($hook) : false;
}
So the problem with trying to use $vbulletin->userdata['userid'] is that $vbulletin isn't in scope. You could add a "global $vbulletin;" line to your plugin code, or you could use the $registry parameter instead since that's probably the same thing.
Whether or not that's the hook you want to use is another question (as nerbert mentioned above). You can work it "backwards", i.e. look at the code for the vb page you're insterested in, then find the fetch_hook() calls that are in locations that are useful to you.
I hope that helps. As for your current project, you didn't give a lot of details, and maybe postdata_start will work for you, but you could also look at function build_new_post() in includes/functions_newpost.php. Hook location newpost_process is good for a lot of purposes.