Log in

View Full Version : trying to make admin cp button visible only to admins


SiXXGuNNZ
12-30-2002, 03:46 AM
okay I used this hack here to hide the register and user cp depending on if you are logged in or out, I also successfully modified it to hide the logout button from guests.

// guest/member register/usercp hack
if($bbuserinfo['userid'] != 0) {
$reg_ucp = "<a href=\"/forum/usercp.php?s=$session[sessionhash]\">".
"<img src=\"https://vborg.vbsupport.ru/images/top_profile.gif\" ".
"alt=\"Here you can view your subscribed threads, work with private messages and edit your profile and preferences\" ".
"border=\"0\"></a>";
}else{
$reg_ucp = "<a href=\"/forum/register.php?s=$session[sessionhash]&action=signup\">".
"<img src=\"https://vborg.vbsupport.ru/images/top_register.gif\" ".
"alt=\"Registration is free!\" border=\"0\"></a>";
}
// guest/member log out hack
if($bbuserinfo['userid'] != 0) {
$log_gone = "<a href=\"/forum/member.php?s=$session[sessionhash]&action=logout\">".
"<img src=\"https://vborg.vbsupport.ru/images/top_logout.gif\" ".
"alt=\"Logout\" border=\"0\"></a>";
}else{
$log_gone = "";
}

now when I apply the same principle to a admin cp button I get errors.

// admin button hack
if($bbuserinfo['userid'] != 6) {
$adcp = "<a href=\"/forum/admin/index.php?s=$session[sessionhash]\">".
"<img src=\"https://vborg.vbsupport.ru/images/top_admincp.gif\" ".
"alt=\"Admin CP\" border=\"0\"></a>";
}else{
$adcp = "";
}

what am I doing wrong?

edit: the above for the admincp works, but guests can also view it :\

SiXXGuNNZ
12-30-2002, 04:47 AM
woot got it

// admin button hack
if($bbuserinfo['usergroupid'] != 6) {
$adcp = "";
}else{
$adcp = "<a href=\"/forum/admin/index.php?s=$session[sessionhash]\">".
"<img src=\"{imagesfolder}/top_admincp.gif\" ".
"alt=\"Admin CP\" border=\"0\"></a>";
}

Boofo
12-30-2002, 08:25 AM
You could have saved yourself all of the php coding on that one by using Logician's Dynamic Templates Hack. You can do all of the conditionals right in the templates themselves. Greatest hack ever made. It's all I use for stuff like this. :)