Can I run custom hooks from a plugin?
#1
I tried adding a custom hook to one of my plugins so I can add stuff to the page with other plugins. I'm having no luck getting anything to work.

Am I able to call custom hooks from a plugin? Or just regular hooks even?

Here's my code where I want to run the hook
$plugins->add_hook("misc_start", "pillars_page");
function pillars_page() {
	global $mybb, $db, $lang, $theme, $templates, $headerinclude, $header, $footer, $plugins;	
	
	if ($mybb->input['action'] != 'pillars') {
		return;	
	}
	
	$data .= 'Exercise<br />';
	$data .= $plugins->run_hooks("exersice_start");
	$data .= "After hook<br />";
	
	// add content to the template
	eval("\$content = \$data;");
	
	// output the page
	eval("\$page = \"".$templates->get("pillars")."\";");
	output_page($page);
}

And here's the code I'm trying to add to that hook
$plugins->add_hook("exercise_start", "custom_hook_test_code");
function custom_hook_test_code(&$data) {
// I've tried like 5 different variations of this and nothing seems to work
	global $data;
	
	$data = str_replace("<br />", "<br /><p>Caught my hook!</p>", $data);
	return $data;
}

I get no errors, but no matter what I do in my other plugin, I can't get my content to display.

Thanks for reading.



SOLVED - Stupid spelling errors!
-TOA
Ordo Ab Chao
"Insanity: doing the same thing over again and expecting different results." - Einstein
Reply


Messages In This Thread
Can I run custom hooks from a plugin? - by TOA - 2012-10-02, 03:25 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)