MyBB Community Forums

Full Version: hooks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
whats the difference between run_hooks and run_hooks_by_ref because when i ry to run the hook "datahandler_post_insert_post" but the function never executes?
run_hooks sends a copy (pass by value) of the arguments to the hook function.
run_hooks_by_ref sends a reference (pass by reference) of the arguments to the hook function.

Basically, with the latter, it means you can modify the argument from within the hook function.
that doesn't seem to be the case here, ad i try to run the hoook to get anything, even a "echo 'Hello';" , that doesn't do anything, its like the hook isn't even running :\

i'm hooking in this way

$plugins->add_hook("datahandler_post_insert_post", "modspam");
and the function it should run is simply
Function modspam(){
echo "test";
}

and like i said, it doesn't do anything
Do you have the redirect page on? Try turning it off. Sometimes that's so quick that it interrupts any echo's.
(2008-06-15, 06:33 PM)labrocca Wrote: [ -> ]Do you have the redirect page on? Try turning it off. Sometimes that's so quick that it interrupts any echo's.

sorry what are you refering to? how do i turn it off?
Even if you turn off "friendly redirect" pages, you may not see "echo" if the page is not outputted (redirect).

A better way of determining whether a hook is run is writing a value to a file, or killing the script with die('test');. They are more aggressive, but you will know for sure.
i've tried die();, and that didn't do anything, it just continued to prossed the new post
Have you activated the plugin? Can you post the plugin file?
well the odd thing is it seems to be working now, as in running, but it seems to be giving a strange error:

[18-Jun-2008 00:40:44] PHP Warning:  spliti() [<a href='function.spliti'>function.spliti</a>]: REG_EMPTY in /home/theexped/public_html/forum/inc/plugins/modspam.php on line 49

i've attached the file
well i've gotten it working, still no idea why it wasn't running in the first place, thanks anyways to everyone that helped
As for the reason why it wasn't working in the first place, the error message pretty much says it - http://au.php.net/spliti

You need an expression for the first argument. (you meant "explode" there I presume, but you've fixed it anyway Toungue)
Pages: 1 2