Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

signin signout

I'm quite new to Wordpress and don't quite understand one simple problem that I have come across when working with the menu tool. I simply want to have the "register" and "login" buttons when the user is not logged in, and show a "profile" and "logout" buttons when they are, and with the theme I am using the login and register buttons seem to be shown regardless of the user status.

Any help would be much appreciated. I hope I've explained the problem enough for you.

1 Answer

Ranish,

I do not work with Wordpress much I work in eCommerce. However, what you are looking for is a flag for the customer/client/user if they are logged in or not.

Wrap your register/login and profile/logout section in a conditional statement like this:

<?php if ($customer->getIsLoggedIn()) : ?>
    Put your profile and logout code here
<?php else : ?>
    Put your register and login code here
<?php endif; ?>

Obviously that is a very abstract example. If you need more specific help I would need to see the section of PHP you are working with to get an idea of how wordpress is checking for logged in state.

Hope this helps.

Thanks Curtis for your kind response and it works. Thanks alot