MyBB Community Forums

Full Version: Help Creating First Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hey,

I'm trying to create a very simple plugin without any knowledge of php. Big Grin

I've taken the hello world plugin and made a few adjustments.

Original:
$plugins->add_hook("pre_output_page", "hello_world");
$plugins->add_hook("postbit", "hello_world_postbit");

New:
$plugins->add_hook("postbit_author_user", "hello_world_postbit");

Original:
function hello_world($page)
{
	$page = str_replace("<div id=\"content\">", "<div id=\"content\"><p>Hello World!<br />This is a sample MyBB Plugin (which can be disabled!) that displays this message on all pages.</p>", $page);
	return $page;
}

function hello_world_postbit($post)
{
	$post['message'] = "<strong>Hello world!</strong><br /><br />{$post['message']}";
}

New:
function hello_world_postbit($post)
{
	$post['warninglevel'] = "{$post['warninglevel']}<br /><strong>Hello world!</strong>";
}

It hasn't worked. Sad

What's going wrong?

Cheers,
Clarkie
Theres no such hook "postbit_author_user"
Use "postbit" as a hook.
Okay thanks I'll try that.
Hmm I changed this
$plugins->add_hook("postbit_author_user", "hello_world_postbit");
to this
$plugins->add_hook("postbit", "hello_world_postbit");

What else do I need to do?
What are you saving the plugin as? (really simple question) Also, did you activate the plugin?
Plugin is activated and it is still hello.php as I'm editing the "Hello World!" plugin.
Try add return $post to the bottom of the postbit function?
What exactly do you mean?

Sorry, I know nothing of php. Sad
function hello_world_postbit($post)
{
    $post['warninglevel'] = "{$post['warninglevel']}<br /><strong>Hello world!</strong>";
    return $post;
}

That's what euantor was saying.
Nope doesn't work...

Any ideas? :/

Thanks for the help by the way.
Pages: 1 2 3