View Full Version : Link questions
FBFKids
06-06-2009, 03:41 PM
Is it possible to put a link on the menu only visible to admins?
Such as a link to the administration area.
Seapyramid
06-06-2009, 03:47 PM
Users you are not authorized to access the admin area with get an error if they click on the admin link so it really can be placed anywhere
Bloodrun
06-06-2009, 03:59 PM
Yes there is go to your functions.php page and in your sidebar function place this(right before the $sidebar = "):
$group = getgroup();
$cancp = cancp($group);
if($cancp == "yes"){
$admin = "<a href='admin.php'><b>ACP</b></a><br>";
}
else{
$admin = "";
}
Then within the &sidebar = ", place this:
".$admin."
Hope I answered your question.
FBFKids
06-06-2009, 04:22 PM
@ Seapyramid. I know they can't access it, and that's not the issue, I'd just like that button to not even be there for them, as it might lead to confusion.
@Bloodrun. That gave me the white screen of death. :/
$group = getgroup();
$cancp = cancp($group);
if($cancp == "yes"){
$admin = "<a href='admin.php'><b>ACP</b></a><br>";
}
else{
$admin = "";
}
$sidebar = "<b><u>".$loggedinname."'s Links:</u></b><br><br>
<a href='adopt.php'>Adopt Some Pets</a><br>
<a href='myadopts.php'>Manage Adoptables</a><br>
<a href='account.php'>Go to My Account</a><br>
".$msgctr."
<a href='logout.php'>Log Out</a>";
".$admin."
}
Is this right?
Bloodrun
06-06-2009, 04:31 PM
@ Seapyramid. I know they can't access it, and that's not the issue, I'd just like that button to not even be there for them, as it might lead to confusion.
@Bloodrun. That gave me the white screen of death. :/
$group = getgroup();
$cancp = cancp($group);
if($cancp == "yes"){
$admin = "<a href='admin.php'><b>ACP</b></a><br>";
}
else{
$admin = "";
}
$sidebar = "<b><u>".$loggedinname."'s Links:</u></b><br><br>
<a href='adopt.php'>Adopt Some Pets</a><br>
<a href='myadopts.php'>Manage Adoptables</a><br>
<a href='account.php'>Go to My Account</a><br>
".$msgctr."
<a href='logout.php'>Log Out</a>";
".$admin."
}
Is this right?
You didn't end the &sidebar correctly
the ".$admin." goes within the ($sidebar = " ";)
FBFKids
06-06-2009, 04:55 PM
So $sidebar = "<b><u>$admin."
???
Bloodrun
06-06-2009, 05:01 PM
So $sidebar = "<b><u>$admin."
???
Use this:
$group = getgroup();
$cancp = cancp($group);
if($cancp == "yes"){
$admin = "<a href='admin.php'><b>ACP</b></a><br>";
}
else{
$admin = "";
}
$sidebar = "<b><u>".$loggedinname."'s Links:</u></b><br><br>
<a href='adopt.php'>Adopt Some Pets</a><br>
<a href='myadopts.php'>Manage Adoptables</a><br>
<a href='account.php'>Go to My Account</a><br>
".$msgctr."
<a href='logout.php'>Log Out</a>
".$admin."";
}
FBFKids
06-06-2009, 05:13 PM
Thank you, works great now.
Bloodrun
06-06-2009, 05:15 PM
Thank you, works great now.
Your welcome. =D
arlecchina
07-18-2009, 12:21 AM
I searched the Forums and this was the most relevant topic I could find so I am posting this here.
I am trying to create links in the links bar that are only visible to users when logged in.
First I commented out this so that it wouldn't pull links from the database.
/*
$links = "";
$query = "SELECT * FROM ".$prefix."links ORDER BY id ASC";
$result = mysql_query($query);
$num = mysql_numrows($result);
//Loop out code
$i=0;
while ($i < $num) {
$linktext=@mysql_result($result,$i,"linktext");
$linkurl=@mysql_result($result,$i,"linkurl");
$linktext = stripslashes($linktext);
$links = $links."<li><a href='".$linkurl."'>".$linktext."</a></li>";
$i++;
}
*/
Then I added this after right before $links:
if($isloggedin == "yes"){
$royallinks = "
<li><a href='pages.php?page=royals'>My Royals</a>
<ul>
<li><a href='adopt.php'>Adopt a Royal</a></li>
<li><a href='myadopts.php'>Care for Royals</a></li>
<li><a href='promo.php'>Rare Royals</a></li>
</ul>
</li>
";
}
else{
$royallinks = "";
}
if($isloggedin == "yes"){
$accountlinks = "
<li><a href='account.php'>Account</a>
<ul>
<li><a href='profile.php?user=".$username."'>View Profile</a></li>
<li><a href='account.php?act=changeemail'>Change Email</a></li>
<li><a href='account.php?act=changepass'>Change Password</a></li>
<li><a href='forgotpass.php'>Reset Password</a></li>
<li><a href='account.php?act=changesettings'>Settings</a></li>
</ul>
</li>";
}
else{
$accountlinks = "";
}
if($isloggedin == "yes"){
$pmlinks ="
<li><a href='messages.php'>Inbox</a></li>
<li><a href='messages.php?act=send'>Compose Message</a></li>";
}
else{
$pmlinks ="";
}
Then I added all my menu links (I am using a drop-down menu which is working fine):
$links = "<ul id='nav' class='dropdown dropdown-horizontal'>
<li><a href='index.php'>Home</a></li>
<li><a href='pages.php?page=about'>About</a>
<ul>
<li><a href='pages.php?page=stages'>Stages</a></li>
<li><a href='pages.php?page=predators'>Predators</a></li>
<li><a href='pages.php?page=npcs'>NPCs</a></li>
<li><a href='pages.php?page=environment'>Environment</a></li>
<li><a href='pages.php?page=occupations'>Occupations</a></li>
</ul>
</li>
".$royallinks."
".$accountlinks."
<li><a href='pages.php?page=communication'>Communication</a>
<ul>
<li><a href='site_news.php'>Announcements</a></li>
".$pmlinks."
<li><a href='stats.php'>Form Alliances</a></li>
<li><a href='profile.php?user='>Members</a></li>
</ul>
</li>
<li><a href='pages.php?page=premium'>Premium Members</a>
<ul>
<li><a href='pages.php?page=donate'>Premium Royals</a></li>
<li><a href='pages.php?page=custom'>Custom Royals</a></li>
<li><a href='pages.php?page=sponsor'>Become a Sponsor</a></li>
</ul>
</li>
<li><a href='pages.php?page=help'>Help</a>
<ul>
<li><a href='pages.php?page=faq'>FAQ</a></li>
<li><a href='pages.php?page=rules'>Rules & Guidelines</a></li>
<li><a href='tos.php'>Terms of Service</a></li>
<li><a href='pages.php?page=privacy'>Privacy Policy</a></li>
<li><a href='pages.php?page=safety'>Safety Tips</a></li>
<li><a href='pages.php?page=parents'>Info for Parents</a></li>
<li><a href='contactus.php'>Contact Us</a></li>
</ul>
</li>
</ul>";
What is NOT working is that even when LOGGED IN the user-only links are still NOT visible. What am I doing wrong? Please advise. Thank you!
BMR777
07-18-2009, 12:38 PM
The second and third pieces of code you have, what files are you placing these in? If you're placing it in the getlinks function in functions.php you might have to call the logincheck() function before using the code, such as this:
$loginstatus = logincheck();
$isloggedin = $loginstatus[loginstatus];
$loggedinname = $loginstatus[username];
if($isloggedin == "yes"){
$royallinks = "
<li><a href='pages.php?page=royals'>My Royals</a>
<ul>
<li><a href='adopt.php'>Adopt a Royal</a></li>
<li><a href='myadopts.php'>Care for Royals</a></li>
<li><a href='promo.php'>Rare Royals</a></li>
</ul>
</li>
";
}
else{
$royallinks = "";
}
if($isloggedin == "yes"){
$accountlinks = "
<li><a href='account.php'>Account</a>
<ul>
<li><a href='profile.php?user=".$username."'>View Profile</a></li>
<li><a href='account.php?act=changeemail'>Change Email</a></li>
<li><a href='account.php?act=changepass'>Change Password</a></li>
<li><a href='forgotpass.php'>Reset Password</a></li>
<li><a href='account.php?act=changesettings'>Settings</a></li>
</ul>
</li>";
}
else{
$accountlinks = "";
}
if($isloggedin == "yes"){
$pmlinks ="
<li><a href='messages.php'>Inbox</a></li>
<li><a href='messages.php?act=send'>Compose Message</a></li>";
}
else{
$pmlinks ="";
}
See if that works. :)
Brandon
arlecchina
07-18-2009, 02:07 PM
That worked, thanks Brandon!
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.