MyBB Community Forums

Full Version: How can I pass additional parameters to run_hooks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I am writing one plugin which will check links in post

$plugins->add_hook("parse_message", "linkchecker");

This plugin is hoocked @ parse_message

Here is the actual method code.


function linkchecker(&$message)
{
      ........
   ...........
}

I want to pass other parameter along with the message to that function. how can I do that?

I want to call this hook using $plugins->run_hooks("linkchecker"); and along with "linkchecker" i want to pass one more paramerter based on that my plugin will check links...

I am looking for some thing like

$plugins->run_hooks("linkchecker", "true"); --> in misc.php

after that

in function

function linkchecker(&$message, $flag)
{
        if($flag)
       {
          .........
          <This is the actual link check logic>
        }
        else
        {
            $message = $message. "<br/><input type="submit" onlcick .....(calll misc.php)..... something like
         }
}

So when ever user come to visit the post he will get a button in post to check links

and once user clicks on that button that will calll misc.php and from threre it will call the same plugin again with flag "true"...

In this way the forum will be fast...

Please help
Take a look at how MyBB does it in inc/class_parser.php.
Do a search for $plugins->run_hooks and it should show you how arguments are passed.
(2009-01-23, 04:10 AM)Yumi Wrote: [ -> ]Take a look at how MyBB does it in inc/class_parser.php.
Do a search for $plugins->run_hooks and it should show you how arguments are passed.

hmmmmmmm

I tried that but u know all hoock calls are using simple function name other than that they are not passing any custom args..

I figured out some alternative way... working on that Smile
On inc/class_parser.php, line 147:
		$message = $plugins->run_hooks("parse_message", $message);
^ Shows how to pass an argument ($message) and return a value from a hook.

Hope that helps.
(2009-01-23, 10:06 AM)Yumi Wrote: [ -> ]On inc/class_parser.php, line 147:
		$message = $plugins->run_hooks("parse_message", $message);
^ Shows how to pass an argument ($message) and return a value from a hook.

Hope that helps.

Yoo Yumi thaks for your reply .. nm I found alternative stuff...

thanks manRolleyes