I want to place a "logout" button in the header part of the theme I am using. This "logout" will be shown only when user is logged in.
How can I do that?
Thanks
teek5449 Sergeant
Joined: Nov 05, 2004
Posts: 148
Posted:
Sun Dec 26, 2004 8:43 am
This should work. Just put the $login wherever you want it to show on your page. Remember to include the $login variable in the global section of your theme.
Code:
/* User info */
cookiedecode($user);/* Get cookie info */
$ip = $_SERVER["REMOTE_ADDR"];
$uname = $cookie[1];
if (!isset($uname)) {
$uname = "$ip";
$guest = 1;
}
if (is_admin($admin)) {/* Display if administrator */
$login = ""._ADMIN." <a href=\"admin.php?op=logout\"> "._LOGOUT." </a> ";/* Admin:[ Logout ] */
}
if (is_user($user)) {/* Display if registered user */
$login .= "<a href=\"modules.php?name=Your_Account&op=logout\"> "._LOGOUT." </a>";
}
else {/* Display if anonymous user */
$login .= ""._BWEL.";
}
anim_chowdhury Corporal
Joined: Nov 17, 2004
Posts: 52
Posted:
Tue Dec 28, 2004 4:08 am
Thanks for the reply.
I am using the login block that comes with 7.5 but it doesnt have a "logut" option after login. What I want is just to show "logout", not "login" in the header of theme since login will be shown in Login Block.
Can you tell me in which file I should put the code? (header.htm / theme.php)
teek5449 Sergeant
Joined: Nov 05, 2004
Posts: 148
Posted:
Tue Dec 28, 2004 8:56 am
The name ($login) is just a variable that you can place anywhere in your theme files that you would like it to show up on your page. BTW I was just too lazy to change the actual name $login to $logoff. I took it from a more complete code that shows a login field if an anonymous user is detected or a welcome message and logoff link if a registered user is detected.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum