Something's not right and I can't figure out what or how to fix it.
I've got the tab showing up. Here's where it might be confusing to follow so I'll try to be simple:
If I use a separate file located in modules, it will work and link the tab to the new page.
But if I use a function within my plugin to try to show the page it won't work (this is the method I would prefer to use as I feel a plugin should be self-contained. What is the common practice on this?).
I'm even using the plugin previously suggested by Paul H as a guide and everything seems fine to me, but it just links back to the admin home page.
Am I missing something? Why is this not working?
Here's my relevant code
/**
* Call Hooks
*/
// add the tab
$plugins->add_hook("admin_page_output_nav_tabs_start", 'adminimportusers_addtab');
// add the action of the tab
$plugins->add_hook("admin_user_action_handler", "adminimportusers_action");
// set permissions
$plugins->add_hook("admin_user_permissions", "adminimportusers_permissions");
// load the page
$plugins->add_hook('admin_load', 'adminimportusers_page');
// Add a tab to the Users & Groups module
function adminimportusers_addtab(&$sub_tabs) {
global $mybb, $lang, $run_module;
// see if the pugin has been enabled in config
if ($mybb->settings['adminimportusers_enable'] == 1) {
// make sure it only shows for the user module
if ($run_module == 'user') {
// now add our tab to the list
$sub_tabs['adminimportusers'] = array(
'id' => 'adminimportusers',
'link' => 'index.php?module=user/adminimportusers',
'description' => 'Import Users into your MyBB forum.',
'title' => 'Import Users',
);
// pass 'em back
return $sub_tabs;
}
}
}
// Now make the link work by adding the action to the meta
function adminimportusers_action(&$actions) {
$actions['adminimportusers'] = array('active' => 'adminimportusers', 'file' => 'adminimportusers');
return $actions;
}
// Lets set some permissions
function adminimportusers_permissions(&$admin_permissions) {
global $db, $mybb, $lang;
$admin_permissions['adminimportusers'] = "Can Import Users?";
return $admin_permissions;
}
// now, the bulk of the script
function adminimportusers_page() {
global $db, $lang, $mybb, $page, $run_module, $action_file;
// don't show this page unless asked and the plugin is enabled
if ($run_module == 'user' && $action_file == 'adminimportusers') {
echo "Catching condition";
}
}
Nevermind, Got it.
Figures; I try for an hour and as soon as I post it I get it.