MyBB Community Forums

Full Version: plugins passed variables?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when a call to a plugin includes a variable as a paremter, such as $this, e.g:

$plugins->run_hooks_by_ref("datahandler_post_insert_thread_post", $this);

is the object being passed ( $this - in the example) available to the corresponding function I have defined in the plugin as a passed parameter, as in:

function myPlugin_thread_post($passedVar )
{
	//$passedVar is the $this object?

}

is that how that works? And variables are passed by reference, right, so anything I do with my functions local parameter will change the original object passed, right?
sorry, I think I am answering my own question there - they are passed by value.

so, you must return the passed variable back.
No, the return value is ignored. It's passed by reference. In that sense, it's function your_hook(&$passedvar) {}. It works also without the & however - it's magic, PHP is strange. Smile

Anyway, just modify the variable directly.

In most other hooks you can modify variables too, even if they aren't passed. MyBB works a lot in the global variable scope...