1
kings
How to tell if someone is logged in
  • 2007/4/26 5:36

  • kings

  • Just popping in

  • Posts: 5

  • Since: 2007/4/21


I want to make a like that either says login or if they are logged in say logout...like


if (userloggedin==no)
a href=www.domainname.com/login.php> login < / a >

if (userloggedin==yes)
a href=www.domainname.com/user.php?op=logout> logout < / a >

thanks for the help

2
Catzwolf
Re: How to tell if someone is logged in
  • 2007/4/26 5:55

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


If php:

if (is_object($xoopsUser)){
echo "is logged in";
} else {
echo "Not logged in";
}

If this is to be in your html or template file:

<{if $xoopsuser}>
is logged in
<{else}>
Not logged in
<{if}>

3
kings
Re: How to tell if someone is logged in
  • 2007/4/26 16:48

  • kings

  • Just popping in

  • Posts: 5

  • Since: 2007/4/21


<{if $xoopsUser}>
<td id="headmenu"><a class="menuHead" href="<{$xoops_url}>/user.php?op=logout">Logout</a></td>
<{else}>
<td id="headmenu"><a class="menuHead" href="<{$xoops_url}>/user.php">Login</a></td>
<{/if}>


However it always seems to go to the else? what am i doing wrong?

by the way its for the theme.html

4
Catzwolf
Re: How to tell if someone is logged in
  • 2007/4/26 17:01

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Whoops I bad, it should be $xoops_isuser

5
tmreg
Re: How to tell if someone is logged in
  • 2007/4/26 17:01

  • tmreg

  • Not too shy to talk

  • Posts: 137

  • Since: 2006/7/20


You need to wrap whatever you want to display in an "if" statement. Start with this:
<{if $xoops_isuser == true}>

and end with this:
<{/if}>


Put whatever html you want in the middle and it will only display when the user os logged on.

Use
<{if $xoops_isuser == false}>

if you want something to display only if the user is not logged in.

I have used this extensively from making custom user menus to having "logged in" icons, to changing headers depending on if you are logged in or not.
-Matt

6
tmreg
Re: How to tell if someone is logged in
  • 2007/4/26 17:08

  • tmreg

  • Not too shy to talk

  • Posts: 137

  • Since: 2006/7/20


Catzwolf, you beat me by seconds.

Kings, either will work.
-Matt

7
kings
Re: How to tell if someone is logged in
  • 2007/4/26 17:22

  • kings

  • Just popping in

  • Posts: 5

  • Since: 2007/4/21


Thanks to the both of you, works great

8
Catzwolf
Re: How to tell if someone is logged in
  • 2007/4/26 17:40

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


When I first posted I wasn't 100% sure, wasn't till King reposted I realised I made a mistake and had to go look it up lol

Anyway, glad it is working for you :)

ATB

Catz

Login

Who's Online

152 user(s) are online (103 user(s) are browsing Support Forums)


Members: 0


Guests: 152


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits