News:

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

Main Menu

Need help coding a Moderator Tab

Started by Bec, September 20, 2008, 12:38:37 PM

Previous topic - Next topic

Bec

Hi Guys,

I need some help coding a new tab so only my moderators can see it, this is my code so far...

            echo '<li' , $current_action=='#' ? ' class="active"' : '' , '><a href="#">Mod Tools</a>
                  <ul style="overflow: hidden; visibility: visible; opacity: 1;">
                     <li><a href="index.php?action=mlist">Members</a></li>
                     <li><a href="index.php?action=stats">Stats</a></li>
                     <li><a href="index.php?action=who">Whos Online</a></li>   
                   </ul>
               </li>';


I just need for only my moderators to be able to see it, they have permission to view the memberlist, online list etc but all members at the moment can the tab..... I want it hidden from everyone else but the mods..

Any ideas?

I am using 1.1.6, Urban design by DzinerStudio

Thanks   :D


Also just as an example this is the code I have for my Global Moderator button....

               if(in_array(2, $GLOBALS['user_info']['groups']))
               {
            echo '<li' , $current_action=='#' ? ' class="active"' : '' , '><a href="#">Mod Tools</a>
                  <ul style="overflow: hidden; visibility: visible; opacity: 1;">         
                     <li><a href="index.php?action=mlist">Members</a></li>
                     <li><a href="index.php?action=stats">Stats</a></li>
                     <li><a href="index.php?action=who">Whos Online</a></li>                     
                   </ul>
               </li>';
               }

Marcus Forsberg

Try the moderate_forum permission. Don't know the exact code for it though.

Marcus Forsberg

#2
Maybe you should put

if ($context['moderate_forum'])

Above

            echo '<li' , $current_action=='#' ? ' class="active"' : '' , '><a href="#">Mod Tools</a>


Not sure that it's right.,.

Bec

Hey Nascar,

Nope that didnt work, its not showing anything... thanks for trying though :) Ive given them permissions I just need the tab to show for them and not everyone else

Marcus Forsberg


Bec


Bec


metallica48423

try $context['is_mod']

moderate_forum is a permission, not a context variable

if you were going to check a permission you'd use the allowedTo function
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Bec

Hi metallica48423,

Nope didnt work, thank you for trying...  :)

so far ive tried

if ($context['is_mod'])

if(in_array(13, $MODERATORS['user_info']['groups'])) - I thought this might work cause it worked for my global mod tab but still nothing

Tony Reid

Shouldn't that be...

if ($context['user']['is_mod'])

     {  // Do stuff here

     }
Tony Reid

Bec

Hi Tony,

Thanks :) just tried that but didnt make any difference

[SiNaN]

#11
If you want it to be shown for board moderators that you assing from Manage Boards?

This code will work:

if(!empty($context['moderators'][$context['user']['id']]))
echo 'I am the mod of this board';
else
echo 'I am nothing';


But, it will only appear when they are in the board they are moderator.

If you have a group for moderators, find its ID (you can see it from the "modify" url in Admin CP >> Membergroups) and use this:

if(in_array('ID_GROUP', $GLOBALS['user_info']['groups']))
Former SMF Core Developer | My Mods | SimplePortal

Tony Reid

Then a cheap trick would be to create a secondary group for moderators (I am guessing that this is not global mods) and then do something similar to what you tried earlier....


global $GLOBALS;

if (in_array(1, $GLOBALS['user_info']['groups'])) 


Changing 1 to be the secondary group number.



*Sorry  Sinan - we double posted.
Tony Reid

Bec

[SiNaN],

Once again your a legend, the second code works perfectly! Thank you so very much!!

Thanks to everyone else for trying, I appreciate the help :)

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

Advertisement: