View Full Version : Checking user group from a non vb page
lightnb
03-14-2006, 11:14 AM
I have the following code in my footer, which is included on every page:
<?php
$forumpath = "http://www.mysite.com/community/forums/";
if ($vbulletin->userinfo['groupid']=6) {
echo "Admin/Mod CP button goes here!";
}
?>
I want it to check to see if the user is logged into vB and is in the admin usergroup, and if so, to display a button that links to the admin cp.
right now, it is showing the button regardless of log in status. what variable does vB use to store the user's usergroup?
thanks,
nick
lightnb
03-17-2006, 10:34 PM
Bump
Freesteyelz
03-17-2006, 11:06 PM
With conditionals I use:
<if condition="is_member_of($bbuserinfo, x)">
Your code here
</if>
Just extract from "is". Where "x" is just replace it with the Usergroup ID. To add more ID's add ", y, z" and so forth.
lightnb
03-19-2006, 03:56 PM
With:
<if condition="is_member_of($bbuserinfo, 6)">
My code here
</if>
I get:
"Parse error: parse error, unexpected '<' in /home/.sites/22/site13/web/livexchange/footer.php on line 66"
lightnb
03-25-2006, 02:27 AM
bump
Freesteyelz
03-25-2006, 05:48 AM
You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:
if ($vbulletin->userinfo['usergroupid']=="6")
{
echo "Admin/Mod CP button goes here!";
}
lightnb
03-26-2006, 03:33 AM
You'll need to adjust the code to make it work. That was just an example conditional used in vB. I'm not sure exactly what the PHP protocol is but maybe:
if ($vbulletin->userinfo['usergroupid']=="6")
{
echo "Admin/Mod CP button goes here!";
}
That doesn't produce any errors, but it doesn't do anything either...
I think there needs to be some other code before it to tell the script that it is looking for a vB variable...
Pickalo
03-26-2006, 06:50 PM
You need to include the config.php I'd say.
Cole2026
03-26-2006, 07:51 PM
No, Config.php just contains server-connect information.
You could do:
$forumpath = "http://www.mysite.com/community/forums";
require_once($forumpath . '/global.php');
global $vbulletin;
if ( is_member_of($vbulletin, 6) )
{
echo "Admin CP and ModCP links go here";
}
unset($vbulletin);
lightnb
03-28-2006, 03:16 AM
Doesn't seem to be working. I tried the code you gave me, but it just causes the page to sit forever, then asks me if i want to run or download the PHP file.
The whole footer is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Xchange Footer</title>
<style type="text/css">
<!--
.style10 {color: #FFFFFF; font-family: Copperplate;}
-->
</style>
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onload="MM_preloadImages('forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif','forums/images/greenleaf/misc/top_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif')">
<table width="850" border="0" cellspacing="0" align="center" cellpadding="0">
<tr height="25">
<td><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/mainbgbottom.jpg" width="850" height="25" /></td>
</tr>
<tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
<td><div align="center">
<table width="850" border="0" cellspacing="0" cellpadding="0">
<tr background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
<td width="258"><div align="left"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/cp.gif" width="257" height="27" /></div></td>
<td width="347" background="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/navbg.gif">
<?PHP
$forumpath = "http://www.rahlentertainment.com/livexchange/forums";
require_once($forumpath . '/global.php');
global $vbulletin;
if ( is_member_of($vbulletin, 6) )
{
echo "Admin CP and ModCP links go here";
}
unset($vbulletin);
?>
</td>
<td width="245"><div align="right"><a href="http://www.rahlentertainment.com/livexchange/forums/sendmessage.php4" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('contactus','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/contact.gif" alt="Contact US" name="contactus" width="71" height="26" border="0" id="contactus" /></a><a href="http://www.rahlentertainment.com/livexchange/privacy.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Privacy','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/privacystatement.gif" alt="Privacy Statement" name="Privacy" width="130" height="26" border="0" id="Privacy" /></a><a href="#top" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('top','','http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top_over.gif',1)"><img src="http://www.rahlentertainment.com/livexchange/forums/images/greenleaf/misc/top.gif" alt="TOP" name="top" width="43" height="26" border="0" id="top" /></a></div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.