UBB.Dev
Posted By: jerry Question with User List function - 07/05/2002 6:40 AM
I see that there is 3 options for showing the user list in the navigation menu:

1. Show to noone
2. Show to everyone
3. Show only to registed users

My question, is it possible to add "Show only to administrator or moderators only"?

Thanks in advance!
Posted By: AllenAyres Re: Question with User List function - 07/05/2002 7:05 PM
welcome

you can use a bandaid approach and edit the navigation menu to do that
Posted By: jerry Re: Question with User List function - 07/08/2002 6:28 AM
I wonder how one would be able to convience InfoPop to hard code this into threads for the next release? Hmm...

Now... how would one even approach this harck? Anyone has an example or insight into this?
Posted By: JustDave Re: Question with User List function - 07/08/2002 6:36 AM
Hi Jerry,

In your ubbt.inc.php file find this:

code:

// -------------------------------------------------
// Are we showing the user list to reged users only?
if ( ($config['userlist'] == '2') || ($config['userlist'] == '1') ){




and change it to this:

code:

// -------------------------------------------------
// Are we showing the user list to reged users only?
if ( ($user['U_Status'] == "Administrator") || ($user['U_Status'] == "Moderator") ){





I think that should do it.

Let me know if it doesn't.
Posted By: jerry Re: Question with User List function - 07/08/2002 7:06 AM
That was quick!

Let me try it out. I'll let you know if there is any problems. Thanks!
Posted By: jerry Re: Question with User List function - 07/08/2002 7:30 AM
This is what I tried. Did a little mod myself

code
// -------------------------------------------------
// Are we showing the user list to reged users only?
if ($config['userlist'] == '1'){
$template['members_link'] = " | <a href="$phpurl/showmembers.php?Cat=$Cat&page=1" target="_top">{$ubbt_lang['USER_LIST']}</a>";
}
else if ( ($user['U_Status'] == "Administrator") || ($user['U_Status'] == "Moderator") ){
$template['members_link'] = " | <a href="$phpurl/showmembers.php?Cat=$Cat&page=1" target="_top">{$ubbt_lang['USER_LIST']}</a>";
}

-------------

It didn't work...
Posted By: jerry Re: Question with User List function - 07/08/2002 7:45 AM
Also I've noticed that this site is set to show the userlist only to registerd users. Well, as an anonymous user, I was able to get the userlist by adding this to the address bar:

https://www.ubbdev.com/threads/php/showmembers.php?Cat=&page=1

To me, this is a bad thing. Our forum (when it's up), we are hopping we can show the userlist only to Admins and Moderators.
Posted By: JustDave Re: Question with User List function - 07/08/2002 8:22 AM
Yes it's done that for a while.

In your showmembers.php file place this:

if ( ($user['U_Status'] != "Administrator") && ($user['U_Status'] != "Moderator") ){
exit;
}

right after this line:

$user = $userob -> authenticate("U_TimeOffset");


That should keep all else from viewing the page.
Posted By: jerry Re: Question with User List function - 07/08/2002 9:38 AM
Got it! It now displays a blank screen but at least it's preventing non Admin & Moderators from viewing the userlist.

Thanks!

Would it be possible to display an error or no access message instead of the blank screen?
Posted By: Lisa_P Re: Question with User List function - 07/08/2002 9:52 AM
Use this:

code:
if( ($user['U_Status'] != 'Administrator') && ($user['U_Status'] != 'Moderator') ) {
$html -> not_right ("You must be logged in, and be a valid administrator or moderator to access this.",$Cat);
}

Posted By: jerry Re: Question with User List function - 07/08/2002 10:38 AM
Hello Lisa_P!

Thanks for the input! Here's what I got when I tried your code:

Fatal error: Call to a member function on a non-object in d:\php\ubbthreads\showmembers.php on line 44

Line 44 is:
code:
$html -> not_right ("You must be logged in, and be a valid administrator or moderator to access this.",$Cat);



Posted By: Lisa_P Re: Question with User List function - 07/08/2002 3:31 PM
Well now, that's not what you wanted is it?!?!

Let's try some better instructions:

Right after the first lines of code:
code:
// Require the library
require ("main.inc.php");
require ("languages/$w3t_language/showmembers.php");



Place this (it's going after the Require stuff, and before " if(!$config['userlist']) { exit; }"
code:

// -----------------
// Get the user info
$userob = new user;
$user = $userob -> authenticate();
$html = new html;

// -----------------------------
// Make sure they should be here
if ($user['U_Status'] != 'Administrator'){
$html -> not_right ("You must be logged in, and be a valid administrator to access this.",$Cat);
}

Posted By: jerry Re: Question with User List function - 07/10/2002 5:00 AM
Thanks Lisa! Works great now!
© UBB.Developers