PDA

View Full Version : Member list to appear only for logged-in users



mathd09
05-17-2010, 02:33 PM
Hi,

Does anybody have an idea on how to restrict viewing "Member list" from non-registered users? I think, this would encourage more registrants and add a little privacy for users.

Something like this message to appear on the page would be ideal,

"Sorry you cannot view this page. Please log-in or register (both must be hyperlinked pointing to registration/log-in page) to enjoy unlimited playing time."

Your help will be very much appreciated. :)

Andy
05-17-2010, 02:38 PM
You can wrap this around any part of the script to make it members only:



if ($user['login_status'] == 1) {
// What to show the user if they are logged in
}
else {
// What to show the user if they are not logged in
}


So put the contents of the member list in the first set of curly brackets and the not logged in message in the other.

mathd09
05-17-2010, 02:51 PM
Hi Andy,

Which file do I place this codes?

Andy
05-17-2010, 02:56 PM
Open includes/misc/member_list.php and replace the contents with:


<?php
if ($user['login_status'] == 1) {
$sql = mysql_query("SELECT * FROM ava_users ORDER BY username");
echo '
<table border="0" cellspacing="0" cellpadding="0" id="member_list">
<tr>
<td></td>
<td><strong>'.ML_USERNAME.'</strong></td>
<td><strong>'.ML_POINTS.'</strong></td>
<td><strong>'.ML_JOIN_DATE.'</strong></td>
</tr>';
while ($row = mysql_fetch_array($sql)) {
$abcd = seoname($row['username']);
if ($setting['seo_on'] == 0) {
$profile_url = $setting['site_url'].'/index.php?task=profile&amp;id='.$row['id'];
$comment_url = $setting['site_url'].'/index.php?task=users_comments&amp;id='.$row['id'];
}
else {
$profile_url = $setting['site_url'].'/profile/'.$row['id'].'/'.$abcd.$setting['seo_extension'];
$comment_url = $setting['site_url'].'/profile/comments/'.$row['id'].'/'.$abcd.$setting['seo_extension'];
}

if($row['points'] == '') {
$points = 0;
}
else {
$points = $row['points'];
}

if($row['avatar'] == '') {
$avatar = '';
}
else {
$avatar = '<img src="'.$setting['site_url'].'/uploads/avatars/'.$row['avatar'].'" width="30" height="30" alt="avatar" />';
}

echo '<tr>
<td>'.$avatar.'</td>
<td><a href="'.$profile_url.'">'.$row['username'].'</a></td>
<td>'.$points.'</td>
<td>'.$row['joined'].'</td>
</tr>';
}

echo' </table>';
}
else {
echo 'Please login to view the members list';
} ?>

mathd09
05-17-2010, 03:21 PM
Wonderful! Thanks, Andy. By the way, can you create a widget system on the sidebar? If not now, hopefully in the future releases.