Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: michaeloeser - lokakuu 21, 2013, 11:36:01 AP

Otsikko: Conditional logic for logged in users only
Kirjoitti: michaeloeser - lokakuu 21, 2013, 11:36:01 AP
I´m looking for a conditional logic for logged in users. Something like this

if (USER IS LOGGED IN) {

   DO SOMETHING
}
else {
   DO SOMETHING ELSE
}

Any ideas? Shouldn´t be difficult but I can´t find the conditional logic.
Otsikko: Re: Conditional logic for logged in users only
Kirjoitti: Arantor - lokakuu 21, 2013, 11:41:13 AP
Depends where you're trying to do this as to what it will be. Where exactly is this going to be?
Otsikko: Re: Conditional logic for logged in users only
Kirjoitti: michaeloeser - lokakuu 21, 2013, 11:44:12 AP
Figured it out by myself.

if ($context['user']['is_logged']) {
template_info_center();
}


So dead simple  ;)
Otsikko: Re: Conditional logic for logged in users only
Kirjoitti: Arantor - lokakuu 21, 2013, 11:49:44 AP
Except it isn't as 'dead simple' as you make it out to be. There are other circumstances where $context['user'] cannot be relied upon and won't even exist. Which is why I asked, but I'm glad you got a solution.
Otsikko: Re: Conditional logic for logged in users only
Kirjoitti: michaeloeser - lokakuu 21, 2013, 11:52:28 AP
Thanks anyway.