Advertisement:

Only admin can view members list

Aloittaja Rogerd, elokuu 15, 2013, 10:17:27 AP

« edellinen - seuraava »

Rogerd

Hi All...I wonder if someone could help me with some coding, I'm trying make the "members" button in the top menu on my forum so it can only be viewed by admins, would be great if someone could add whats needed to the code below for me, as i'm hopeless at coding.

   // the [member] list button
   if ($context['allow_memberlist'])
      echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
            </td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

Many thanks in anticipation of a reply.

Arantor

You shouldn't have to change the file itself, just alter the permissions in the admin panel - access should be controlled by the 'view the member list' permission, and if a user doesn't have permission they shouldn't be able to see it...
Holder of controversial views, all of which my own.


Rogerd

Sorry I didn't explain myself very well, I have the permissions set so only admins can view the member list, other member groups can still see the button and keep asking why the button is there if their not allowed to view the members list, wondered if it could be coded like the admin button, so only admins can see the actual button, thanks.

Arantor

That's interesting because it shouldn't be doing that and that suggests you have either a broken mod or a broken theme that is screwing it up. There is nothing wrong with the code you have above, $context['allow_memberlist'] is defined elsewhere in the code and for some reason it is not being set correctly.

It would help to know what version of SMF, what theme and what mods you have.
Holder of controversial views, all of which my own.


Rogerd

I'm using SMF version 1.1.18, on the default theme, I have 61 mods on my site, which is why i thought if some code could be added to the example in my first post similar to the "admin" button, the "members" button would then only show for admins, I may be talking rubbish here, but it makes sense to me LOL, thanks.

This code is taken from the "admin" button code, could something similar be used on the "members" button:

   // Is the user allowed to administrate at all? ([admin])
   if ($context['allow_admin'])
      echo ($current_action == 'admin' ||

Rogerd


Advertisement: