MyBB Community Forums

Full Version: how to add a menu to the user cp
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok i a new to make plugins to mybb but i am tring to work out to add a new text like to the user cp eg on Miscellaneous Dodgy as i need a link to show for the rest of my plug-ins as it need to got to a new page for my plugin to work i not even do this part yet as there is not point in doing so unless the basics have been done

cheers

thank you for your help
Just edit the template "usercp_nav_misc." Just copy/paste a line, then edit it to your likings.
ok thank you i only want the link to show when my plugin is active so do i use usercp_nav_misc as a hook? and just added the html code link i want to show.
You insert your HTML modifications when in your plugin's activate function. When you deactivate the plugin, you remove the HTML modifications to the template. See the find_replace_templatesets function in inc/adminfunctions_templates.php
is this right cos i dont seem to be working
<?php

function MemberRefer_info()

{

	return array(

		'name'			=> 'plugin infor',

		'description'	=> 'what it dose',

		'website'		=> 'site.com',

		'author'		=> 'tazfan',

		'authorsite'	=> 'site.com',

		'version'		=> '1.0'

		"guid"			=> "Okcjhfieloksie8kd",

		"compatibility" => "14*",

	);

}

function MemberRefer_activate()

{

	// start of the mod when it is active
$addlink->add_hook("usercp_nav_misc ", "<tr><td class="trow1 smalltext"><a href="page.php" class="usercp_nav_item usercp_nav_usergroups">The link</a></td></tr>");
	

}

function MemberRefer_deactivate()

{

	// end of script
	

}


?>

cos for some reason i get


Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/user/public_html/site/forums/inc/plugins/MemberRefer.php on line 11
That is not correct. "add_hook" always goes before any of the functions in your plugin. Plus, you must use the find_replace_templatesets function to add things into templates.

Also, are you using MemberRefer_activate as your run function? If so, that doesn't work. The _activate and _deactivate are for when you activate and deactivate the plugin in your ACP.

I suggest browsing through some plugins (perhaps Ryan's, since he explains most of what goes on in his plugins).
a i i see what i have been doing wrong and yes Ryans plugins are great to learn from i miss this when i program with people do not comment Big Grin

thank you Ryan for making your plugins easy to fellow and RenegadeFan cheers for the heads up Big Grin
ok sorry guys i need more help

would this be right to get the link added to the menu when the user has the plugin activate

function memberrefer_activate()
{
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("usercp_nav_misc", '#{\<tr><td class="trow1 smalltext"><a href="page.php" class="usercp_nav_item usercp_nav_usergroups">The link</a></td></tr>");

}

if not what would i do Confused
It needs to be like this:
function memberrefer_activate()
{
include MYBB_ROOT."/inc/adminfunctions_templates.php";
find_replace_templatesets("usercp_nav_misc", '#'.preg_quote('{$lang->ucp_nav_view_profile}</a></td></tr>').'#', '{$lang->ucp_nav_view_profile}</a></td></tr><tr><td class="trow1 smalltext"><a href="page.php" class="usercp_nav_item usercp_nav_usergroups">The link</a></td></tr>';

}
That will find the last link under the "Miscellaneous" category (View Profile by default) and add your link under it.