News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How to add one new link in the menu to a specific group?

Started by HecKel, May 27, 2008, 06:40:34 AM

Previous topic - Next topic

[SiNaN]

Okay, this is your menu button:

$mygroups= array(1,2,3,4,5,6,7,1453,1071);
$permit = false;
foreach ($mygroups as $group) {
if(in_array($group, $user_info['groups']))
$permit = true;
}
if (!$context['user']['is_guest'] && $permit){
// Show the [custom] button.
echo ($current_action == 'custom' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'custom' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=custom">Custom Button</a>
</td>' , $current_action == 'custom' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
}


1,2,3,4,5,6,7,1453,1071 are the membergroup ID's seperated by comma.

Do not forget to add the $user_info as global. Like this:

Find:
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;


Replace:
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt, $user_info;
Former SMF Core Developer | My Mods | SimplePortal

HecKel

Quote from: Eliana Tamerin on August 23, 2008, 04:10:10 PM
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P

ccbtimewiz


FragaCampos

Hello.
Sorry to unearth this topic, but although it has been very useful, i'm getting some errors in my log because of it. It's nothing serious, but i get hundreds of messages, which isn't nice :P

The error is:
2: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument
File: public_html/Themes/default/BoardIndex.template.php
Line: 414


and the line in question is:
if(in_array($group, $user_info['groups'])).

Can someone help me clean this?
Thanks a lot.

FragaCampos


Advertisement: