php code for "if logged in" vs "if not logged in"

Permalink
I'd like a login box to appear if not logged in. Otherwise, that area should show a Search box.

 
codingpenguins replied on at Permalink Best Answer Reply
Well I know there is two ways that I know of
$u = new User();
if($u->isLoggedIn()) {
   //search box
} else {
   //login box
}


The other way is ($u->getUserID()!='')//this means they are logged in. I think the above way is better.

Or did you also want the code for login and search box?
zoinks replied on at Permalink Reply
Thanks, I believe this is what I wanted if this is the correct code to get it to work with Concrete5. I just wasn't sure what keyword C5 might use to signify logged in vs. logged out.

I have the searchbox and login box all coded up, so presumably I can just put the correct bits in the corresponding spaces where you have your //comments ...is that right?
codingpenguins replied on at Permalink Reply
Yeah, that is exactly right. and this is the right "concrete5" way of doing it ; )
codingpenguins replied on at Permalink Reply
Actually My code was backward. I edit the comment, so it will display correctly!
zoinks replied on at Permalink Reply
thanks!

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.