MyBB Community Forums
sub_menu and actions hook - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: sub_menu and actions hook (/thread-185431.html)



sub_menu and actions hook - chack1172 - 2015-10-21

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?


RE: sub_menu and actions hook - Omar G. - 2015-10-22

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.


RE: sub_menu and actions hook - chack1172 - 2015-10-22

Thank you, @Omar G..
Now it works