MyBB Community Forums

Full Version: sub_menu and actions hook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys,
I'm developing a plugin but I have an issue.

this is the part of the plugin affected:

// after <?php
$plugins->add_hook("admin_forum_menu", "myplugin_sub_menu");
$plugins->add_hook("admin_forum_action_handler", "myplugin_action");

// end of file 

function myplugin_sub_menu() {
    $sub_menu['100'] = array("id" => "alerts", "title" => "Forum Alerts", "link" => "index.php?module=forum-alerts");   
}

function myplugin_action() {
    $actions['alerts'] = array('active' => 'alerts', 'file' => 'alerts.php');
}

Why it don't add submenu at forum module?
You need to pass those arguments by reference.

function foo_sub_menu(&$sub_menu) {
    $sub_menu[] = array("id" => "foo", "title" => "Foo", "link" => "index.php?module=config-foo");   
}

function foo_action(&$actions) {
    $actions['foo'] = array('active' => 'foo', 'file' => 'foo.php');
} 

Otherwise you are actually doing nothing.
Thank you, @Omar G..
Now it works