How to hide memberlist from users that are not logged in?

This is an archive of the phpBB 2.0.x support forum. Support for phpBB2 has now ended.
Forum rules
Following phpBB2's EoL, this forum is now archived for reference purposes only.
Please see the following announcement for more information: viewtopic.php?f=14&t=1385785
Locked
merced
Registered User
Posts: 7
Joined: Wed May 18, 2005 8:00 pm
Location: Karlstad, Sweden
Contact:

How to hide memberlist from users that are not logged in?

Post by merced »

I have started a forum where I only want registered user to be able to see the memberlist. So, if you are not logged in the memberlist should not be visible, but logged in users should be able to see it.
Is this possible?
Is there anyone here who knows how?
mtx
Registered User
Posts: 494
Joined: Fri Dec 17, 2004 5:42 pm

Post by mtx »

I use this.
Open profile.php
Find

Code: Select all

// 
// Set default email variables 
// 
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path'])); 
$script_name = ( $script_name != '' ) ? $script_name . '/profile.'.$phpEx : 'profile.'.$phpEx; 
$server_name = trim($board_config['server_name']); 
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://'; 
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/'; 

$server_url = $server_protocol . $server_name . $server_port . $script_name;
Insert this before

Code: Select all

// Begin 'Restrict Guest Access' MOD 
$u = ( isset($HTTP_GET_VARS[POST_USERS_URL]) ) ? intval($HTTP_GET_VARS[POST_USERS_URL]) : intval($HTTP_POST_VARS[POST_USERS_URL]); 

$mode = ( isset($HTTP_GET_VARS['mode']) ) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode']; 
if ( !$userdata['session_logged_in'] && $mode == 'viewprofile') 
{ 
// redirect("login.".$phpEx."?redirect=profile.".$phpEx."&mode=viewprofile&".POST_USERS_URL."=".$u); 
redirect(append_sid("login.$phpEx?redirect=profile.$phpEx&mode=viewprofile&".POST_USERS_URL."=".$u, true)); 
exit; 
} 
// End 'Restrict Guest Access' MOD 
kislany
Registered User
Posts: 8
Joined: Mon May 09, 2005 11:41 pm
Location: UK
Contact:

Post by kislany »

That didnt work for me, any advice ?
mtx
Registered User
Posts: 494
Joined: Fri Dec 17, 2004 5:42 pm

Post by mtx »

open memberlist.php
find

Code: Select all

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_VIEWMEMBERS);
init_userprefs($userdata);
//
// End session management
//
put this after

Code: Select all

// Begin 'Restrict Guest Access' MOD 
if ( !$userdata['session_logged_in'] ) 
   { 
      redirect("login.".$phpEx."?redirect=memberlist.".$phpEx); 
      exit; 
   } 
// End 'Restrict Guest Access' MOD
merced
Registered User
Posts: 7
Joined: Wed May 18, 2005 8:00 pm
Location: Karlstad, Sweden
Contact:

Post by merced »

Thanx! That last piece of code worked really good. :D
TMagnum
Registered User
Posts: 107
Joined: Mon Aug 01, 2005 8:27 am

Post by TMagnum »

this worked great for me!! thank you!!!
mlines
Registered User
Posts: 1
Joined: Thu Dec 22, 2005 8:40 pm
Location: edmonton

Post by mlines »

worked good for me too. Thanks.
milem
Registered User
Posts: 2
Joined: Sun Dec 18, 2005 6:52 pm

Post by milem »

great that works
thank you :D :lol:
VoreLord
Registered User
Posts: 12
Joined: Thu Dec 08, 2005 10:19 pm

Post by VoreLord »

Great code !!!!! :)
SER
Registered User
Posts: 1308
Joined: Fri Sep 06, 2002 6:09 am
Location: N 34 3 8 / W 118 14 33

Post by SER »

And if you want go further than that, try:
Redirect anonymous users to login MOD.
Visual Guide to Avatar Galleries
The Unoficial Staff Forum For The Unofficial Support Team | Join me at HauntX Remember, if it's Haunted, it's here!
"Support helps those who help themselves." | "You can lead a fool to wisdom, but you cannot make him think."
Locked

Return to “2.0.x Support Forum”