Little Question

Discuss the development of future releases of phpBB (phpBB 3.x minor releases) and MODing/Coding related questions.
Post Reply
User avatar
EY
Supporter
Supporter
Posts: 204
Joined: 05 Nov 2006, 23:13
Real name: Elias
Location: Montreal

Little Question

Post by EY »

Hello there!

Heres an if statement for if you are a guest:

Code: Select all

if ($user->data['user_id'] != ANONYMOUS)
{
do this
}


What would be the code for lets say If user is logged in?

Thanks in advance.
Never Say Never!
User avatar
onehundredandtwo
Past Contributor
Past Contributor
Posts: 48
Joined: 23 Jul 2009, 19:47

Re: Little Question

Post by onehundredandtwo »

This code should work.

Code: Select all

if(!$user->data['is_registered'])
{
    echo 'User is not logged in';
}
else
{
    echo 'User is logged in';
}
User avatar
Semi_Deus
Past Contributor
Past Contributor
Posts: 405
Joined: 28 Sep 2007, 23:52
Location: the Netherlands
Contact:

Re: Little Question

Post by Semi_Deus »

onehundredandtwo wrote:This code should work.

Code: Select all

if(!$user->data['is_registered'])
{
    echo 'User is not logged in';
}
else
{
    echo 'User is logged in';
}

I'm not a decent coder, but if I look at this and translate it, it doesn't really make sense to me :|
It translates to me like this:

If a user is registered, say: User is not logged in. If he's not registered, say: User is logged in.
no? my mistake if not, but..
Image
Keep an eye on us, were back in business..
User avatar
Obsidian
Supporter
Supporter
Posts: 736
Joined: 13 May 2008, 15:20
Real name: Damian
Contact:

Re: Little Question

Post by Obsidian »

Note the ! at the start of the if statement's condition. It inverts the logic. ;)
User avatar
bonelifer
Administrator
Administrator
Posts: 477
Joined: 24 Jun 2006, 17:48
Real name: William
Location: htpc.MythBuntu

Re: Little Question

Post by bonelifer »

It says "If user NOT logged in {do this}, else user is logged in {do that}".
User avatar
EY
Supporter
Supporter
Posts: 204
Joined: 05 Nov 2006, 23:13
Real name: Elias
Location: Montreal

Re: Little Question

Post by EY »

Yes sorry i wrote the wrong code for this :oops:
Never Say Never!
User avatar
Semi_Deus
Past Contributor
Past Contributor
Posts: 405
Joined: 28 Sep 2007, 23:52
Location: the Netherlands
Contact:

Re: Little Question

Post by Semi_Deus »

Ah okay, thanks guys :)
Image
Keep an eye on us, were back in business..
User avatar
bonelifer
Administrator
Administrator
Posts: 477
Joined: 24 Jun 2006, 17:48
Real name: William
Location: htpc.MythBuntu

Re: Little Question

Post by bonelifer »

Elias is that an avatar of your dog? It's cute either way.
Post Reply