[How to] Add new/custom hook locations
This guide will teach you how to add your own hook locations to your scripts/default vBulletin source code. Note that I assume that you are working within the vBulletin.php files or you have included vBulletin's global.php.
Adding custom hook locations - Method one: See paul's thread here for the best method, if you are going to release your modification to the public this is the way you should go: https://vborg.vbsupport.ru/showthread.php?t=83390 Method two: All hooks listed in this drop down live in the .xml file located at /vbroot/includes/xml/hooks_vbulletin.xml Find this bit of code at the very top of the file: HTML Code:
<hooks> Looks simple eh? Heres what these tags do <hooks> - anything between this tag and </hooks> will be included in the drop down <hooktype type="name"> - The name of your hook group, you should group all common hooks under a group so you can find them quickly. Make sure you don't use a name already used by a default hooktype. <hook> - The name of your hook, this must be the same as the hook's name in the php code Here is an example of my .xml file, I added three custom hooks under a new hooktype: HTML Code:
<hooks> Adding a hook location to the php code is easy, just make sure you use the correct hook name! Use this bit of php anywhere after your call to global.php to call your custom hook. Also note that you must use the $hook var! PHP Code:
PHP Code:
Now all you need to do is browse to your admincp's add new plug-in page and test your new hook location! I use this just to make sure it is working correctly: PHP Code:
|
Great job, nice of you to share
|
Very handy information
|
it's ok with me , thank you
|
If I might offer a suggestion... if were to add custom hooks in my code and upgrade my forums later, I would want to be able to find my hooks I entered easily so I can re-enter them if needed.
My suggestion: Instead of doing this: PHP Code:
PHP Code:
Only a thought I would share. Noone has to use it! :nervous: |
Ok I think I forgot it but what are hooks used for ? (in the programming term, not end-users)
something like this line: PHP Code:
|
Hooks are used to execute raw php code in the files.
Basicly that bit of code does this: Checks if hooks are on in vboptions, checks if any hooks exist for that hook location. If any hooks are found and enabled your custom php code is set to the $hook var If there is php code set to $hook it is sent to eval for the php code to be executed, if not nothing is done and php moves on to the rest of the code in the file. |
many thanks, I understand it now and is writing my hack.
|
If you are adding custom hooks, you might want to read this as well.
https://vborg.vbsupport.ru/showthread.php?t=83390 |
Quote:
|
Tomato (A), tomato (o). Same idea.
It would be nice to have something that could be considered "unofficially standard" so if anyone created an update script that searched for custom hooks, a universal pattern could be looked for. Granted that this would be completely up to the forum admin. Thus, the suggested $customhook rather than $hook for the variable name. |
fantastic article - cheers
|
Quote:
But today I noticed Warnings in the Webserver-Logfile concerning the Lines the Hooks where called: PHP Warning: Call-time pass-by-reference has been deprecated - argument passed by value; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. However, future versions may not support this any longer. in .../includes/init.php(403) : eval()'d code on line 52, .... Does this mean that future PHP-versions won't support the vBulletin-Hook-System? |
All times are GMT. The time now is 12:03 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|