Hiding memberlist from guests or everyone(except admin)

This forum contains some common phpBB2 problems and solutions as well as a selection of useful tutorials.

Moderators: Moderator Team, phpBB Moderators

Forum rules/notes
You use any of the fixes listed in this forum at your own risk. You should make full backups before applying any changes to your board. This site is not affiliated with phpBB.com and as such the phpBB team can and will not be held accountable for any issues which arise from using any of the fixes in this forum. Some of the topics here are clones of articles taken from the phpBB.com knowledge base.

Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 11 Mar 2007 11:22

Hiding from guests


Open {root}/memberlist.php
Find:
Code: Select all
init_userprefs($userdata);

After, add:
Code: Select all
if ($userdata['user_id'] == ANONYMOUS)
{
    redirect(append_sid("login.$phpEx?redirect=memberlist.$phpEx", true));
}


Hiding from all but admin


Open {root}/memberlist.php
Find:
Code: Select all
init_userprefs($userdata);

After, add:
Code: Select all
if ($userdata['user_level'] != ADMIN)
{
    message_die(GENERAL_ERROR, 'Only Administrators can access this area');
}

Open {root}/includes/page_header.php
Find:
Code: Select all
else
{
   $template->assign_block_vars('switch_user_logged_in', array());

   if ( !empty($userdata['user_popup_pm']) )
   {
      $template->assign_block_vars('switch_enable_pm_popup', array());
   }
}

After Add:
Code: Select all
if ( $userdata['user_level'] == ADMIN )
{
     $template->assign_block_vars('switch_admin_logged_in',array() );
}

Open {root}/templates/subSilver/overall_header.tpl
Find:
Code: Select all
<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a>&nbsp; &nbsp;<a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>&nbsp; &nbsp;<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>&nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>&nbsp;

Replace with:
Code: Select all
<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a>&nbsp; &nbsp;<a href="{U_SEARCH}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="{L_SEARCH}" hspace="3" />{L_SEARCH}</a>
                  <!-- BEGIN switch_admin_logged_in -->
                  &nbsp; &nbsp;<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>
                  <!-- END switch_admin_logged_in -->
                  &nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>&nbsp;
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Hiding memberlist from guests or everyone(except admin)

Sponsor

Sponsor
 

Re: Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 27 Mar 2007 07:07

Obviously this is something which can be initiated on all pages Smile

Open {root}/faq.php, groupcp.php, index.php, memberlist.php, search.php, viewforum.php, viewonline.php, viewtopic.php, posting.php
Find:
Code: Select all
init_userprefs($userdata);

After, add:
Code: Select all
if ($userdata['user_id'] == ANONYMOUS)
{
redirect(append_sid('login.'.$phpEx));
}


Open {root}/profile.php
Find:
Code: Select all
   if ( $mode == 'viewprofile' )
   {
      include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
      exit;
   }

Replace with:
Code: Select all
   if ( $mode == 'viewprofile' )
   {
      if ($userdata['user_id'] == ANONYMOUS)
      {
      redirect(append_sid('login.'.$phpEx));
      }

      include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
      exit;
   }
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Re: Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 24 Jun 2007 13:07

Obviously this is something which can be done to stop everyone but Admin :):)

Open {root}/faq.php, groupcp.php, index.php, memberlist.php, search.php, viewforum.php, viewonline.php, viewtopic.php, posting.php
Find:
Code: Select all
init_userprefs($userdata);

After, add:
Code: Select all
if ($userdata['user_level'] != ADMIN)
{
message_die(GENERAL_ERROR, 'Only Administrators can access this area');
}


Open {root}/profile.php
Find:
Code: Select all
   if ( $mode == 'viewprofile' )
   {
      include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
      exit;
   }

Replace with:
Code: Select all
   if ( $mode == 'viewprofile' )
   {
      if ($userdata['user_level'] != ADMIN)
      {
       message_die(GENERAL_ERROR, 'Only Administrators can access this area');
      }

      include($phpbb_root_path . 'includes/usercp_viewprofile.'.$phpEx);
      exit;
   }
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Re: Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 16 Oct 2007 09:11

Lumpy Burgertushie wrote:
Code: Select all
#This is a collection of edits that will do what you asked.
#As with any MODs, be sure to work from copies, that way you
#can always recover with a couple of clicks.
#
# Hides memberlist and groups links in overall_header.tpl  to admin only.
#-----[ OPEN ]------------------------------------------
#

includes/page_header.php

#
#-----[ FIND ]------------------------------------------
#

if ( !empty($userdata['user_popup_pm']) )
   {
      $template->assign_block_vars('switch_enable_pm_popup', array());
   }
#
#-----[ AFTER, ADD ]------------------------------------------
#

// Admin Only View Mod   
   if ( $userdata['user_level'] == ADMIN )
   {
      $template->assign_block_vars('switch_admin_view_only', array());
   }
// Admin Only View Mod


#
#-----[ OPEN ]------------------------------------------
#

templates/yourstyle/overall_header.tpl

#
#-----[ FIND ]------------------------------------------
#
<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>
&nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
&nbsp;

#
#-----[ REPLACE WITH ]------------------------------------------
#Make sure you place the switches on a line by themselves or they
#wont work.
#
<!-- BEGIN switch_admin_view_only -->
<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>
&nbsp; &nbsp;
<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
&nbsp;
<!-- END switch_admin_view_only -->




#
#This restricts the memberlist to members only.
#-----[ OPEN ]------------------------------------------
#

memberlist.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#

// Begin 'Restrict Access'
if ( !$userdata['session_logged_in'] )
   {
      redirect(append_sid("login.".$phpEx."?redirect=memberlist.".$phpEx, true));
      exit;
   }
// End 'Restrict Access'



#
#This restricts memberlist to admin only
#-----[ OPEN ]------------------------------------------
#

memberlist.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#


// Begin 'Restrict Access'
if( !$userdata['user_level'] == 1 )
{
message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}
   
// End 'Restrict Access'
#
#This restricts memberlist to certain groups only
#-----[ OPEN ]------------------------------------------
#
memberlist.php
#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#
//Begin restrict guest access MOD
// Change this number to the ID # of the group you want to restrict access to
$page_group = 1;

$sql = "SELECT group_id FROM " . USER_GROUPS_TABLE . "
   WHERE user_id = " . $userdata['user_id'] . "
   AND group_id = " . $page_group;
if(!($result = $db->sql_query($sql)))
   message_die(GENERAL_ERROR,'Could not select from usergroup table','',__LINE__,__FILE__,$sql);

$row = $db->sql_fetchrow($result);

if(empty($row))
   redirect($phpbb_root_path . 'index.'.$phpEx);
//End restrict guest access MOD

#
#show the memberlist and user groups links to members only
#-----[ OPEN ]------------------------------------------
#

templates/yourstyle/overall_header.tpl

#
#-----[ FIND ]------------------------------------------
#
<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>
&nbsp; &nbsp;<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
&nbsp;

#
#-----[ REPLACE WITH ]------------------------------------------
#Make sure you place the switches on a line by themselves or they
#wont work.
#
<!-- BEGIN switch_user_logged_in -->
<a href="{U_MEMBERLIST}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_members.gif" width="12" height="13" border="0" alt="{L_MEMBERLIST}" hspace="3" />{L_MEMBERLIST}</a>
&nbsp; &nbsp;
<a href="{U_GROUP_CP}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_groups.gif" width="12" height="13" border="0" alt="{L_USERGROUPS}" hspace="3" />{L_USERGROUPS}</a>
&nbsp;
<!-- END switch_user_logged_in -->

#
#This restricts the groups page to members only.
#-----[ OPEN ]------------------------------------------
#

groupcp.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#

// Begin 'Restrict Access'
if ( !$userdata['session_logged_in'] )
   {
      redirect(append_sid("login.".$phpEx."?redirect=groupcp.".$phpEx, true));
      exit;
   }
// End 'Restrict Access'

#This restricts the profile.php file to members only.
#-----[ OPEN ]---------------------------------------------
#
profile.php

#
#-----[ FIND ]---------------------------------------------
#
   if ( $mode == 'viewprofile' )
   {

#
#-----[ AFTER, ADD ]---------------------------------------------
#
      if ($userdata['user_id'] == ANONYMOUS)
      {
         redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=viewprofile&" . POST_USERS_URL . '=' . intval($HTTP_GET_VARS[POST_USERS_URL]), true));
      }

#
#-----[ OPEN ]------------------------------------------
#

search.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#

if( !$userdata['session_logged_in'] || !isset($userdata))
{
redirect("login.$phpEx?redirect=search.$phpEx");
}

#This will show the poster's info only to members.
#-----[ OPEN ]------------------------------------------
#

templates/yourstyle/viewtopic_body.tpl

#
#-----[ FIND ]------------------------------------------
#
{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}
#
#-----[ REPLACE WITH ]------------------------------------------
#
<!-- BEGIN switch_user_logged_in -->
{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}
<!-- END switch_user_logged_in -->
#This will remove the poster's info from the viewtopic page.
#-----[ OPEN ]------------------------------------------
#

templates/yourstyle/viewtopic_body.tpl

#
#-----[ FIND AND DELETE]------------------------------------------
#
{postrow.POSTER_JOINED}<br />{postrow.POSTER_POSTS}<br />{postrow.POSTER_FROM}
#
#-----[ OPEN ]------------------------------------------
#

viewtopic.php

#
#-----[ FIND ]------------------------------------------
#

if ( $poster_id != ANONYMOUS )
{
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");

#
#-----[ REPLACE WITH ]------------------------------------
#

if ( $poster_id != ANONYMOUS && $userdata['session_logged_in'] )
{
$temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
#
#This will remove the whos online box from the page
#-----[ OPEN ]------------------------------------------
#

templates/yourstyle/index_body.tpl

#
#-----[ FIND ]------------------------------------------
#

<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
  <tr>
   <td class="catHead" colspan="2" height="28"><span class="cattitle"><a href="{U_VIEWONLINE}" class="cattitle">{L_WHO_IS_ONLINE}</a></span></td>
  </tr>
  <tr>
   <td class="row1" align="center" valign="middle" rowspan="2"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
   <td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
   </td>
  </tr>
  <tr>
   <td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
  </tr>
</table>

<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
   <td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
</table>
#
#-----[ REPLACE WITH ]------------------------------------------
#
#
<!--this is commenting out the code
<table width="100%" cellpadding="3" cellspacing="1" border="0" class="forumline">
  <tr>
   <td class="catHead" colspan="2" height="28"><span class="cattitle"><a href="{U_VIEWONLINE}" class="cattitle">{L_WHO_IS_ONLINE}</a></span></td>
  </tr>
  <tr>
   <td class="row1" align="center" valign="middle" rowspan="2"><img src="templates/subSilver/images/whosonline.gif" alt="{L_WHO_IS_ONLINE}" /></td>
   <td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</span>
   </td>
  </tr>
  <tr>
   <td class="row1" align="left"><span class="gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}</span></td>
  </tr>
</table>

<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
   <td align="left" valign="top"><span class="gensmall">{L_ONLINE_EXPLAIN}</span></td>
</tr>
</table>
-->
#This will make the whos online file available to only members
#-----[ OPEN ]------------------------------------------
#

viewonline.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#

// Begin 'Restrict Access'
if ( !$userdata['session_logged_in'] )
   {
      redirect(append_sid("login.".$phpEx."?redirect=viewonline.".$phpEx, true));
      exit;
   }
// End 'Restrict Access'
#
#This will make the whos online file available to only admin
#-----[ OPEN ]------------------------------------------
#

viewonline.php

#
#-----[ FIND ]------------------------------------------
#

//
// End session management
//

#
#-----[ AFTER, ADD ]------------------------------------
#

// Begin 'Restrict Access'
if( !$userdata['user_level'] == 1 )
{
message_die(GENERAL_MESSAGE, $lang['Not_Authorised']);
}
   
// End 'Restrict Access'
#-----[ EOM ]------
#----[ CLOSE, SAVE and UPLOAD ALL FILES ]----
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Re: Hiding memberlist from guests or everyone(except admin)

Postby Guest » 14 Oct 2008 21:48

Thanks Jackal!

Works fine //perfect
User avatar
Guest
 

Re: Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 15 Oct 2008 07:05

Guest wrote:Thanks Jackal!

Works fine //perfect


Good good //wtg
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Re: Hiding memberlist from guests or everyone(except admin)

Postby colliope » 12 Nov 2008 19:59

I just found this thread and it made it so easy to "lock down" the forum from unregistered people.

Thanks, Jackal!
User avatar
colliope
 

Re: Hiding memberlist from guests or everyone(except admin)

Postby Jackal » 13 Nov 2008 05:20

You are very welcome :)
Click here for my blog && Support Evie-Jo
Image








//firefox
User avatar
Jackal
Evil Admin
Evil Admin
 
Posts: 46,383
Joined: 22 Oct 2004 17:34
Location: Hereford UK
Blog: View Blog (2)
Gender: Male

Re: Hiding memberlist from guests or everyone(except admin)

Postby Mario » 18 Feb 2009 11:16

this works great karl , just brilliantly //perfect
User avatar
Mario
Bit of a Nutter!
Bit of a Nutter!
 
Posts: 262
Joined: 13 Feb 2008 15:24
Gender: Male


Return to Common phpBB2 problems and tutorials

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests