Hiding Login, Logout, and Register Links

One of the great EE features is the robust site membership module. In order to allow site visitors to login, logout, or register with your site, you need to create links to those corresponding membership templates. The easy way is simply to create these links so they all show on your pages, like this:





<a href=”{path=logout}”>Logout</a><br />


<a href=”{path=member/login}”>Login</a><br />


<a href=”{path=member/register}”>Register</a><br />






But, since a logged-in user probably does not need to see a “Login” or “Register” link, and a logged-out user probably does not need to see a “Logout” link, I think it is a little more user-friendly to hide these “Login,” “Logout,” and “Register” links depending on whether a user is logged in or logged out. Here is how to do it.

Using EE’s nifty Conditional Global Variables, it is easy to create Login, Logout, and Register links that appear or disappear depending on whether someone is logged in or logged out.





{if logged_in}


<a href=”{path=logout}”>Logout</a><br />


{/if}


{if logged_out}


<a href=”{path=member/login}”>Login</a><br />


<a href=”{path=member/register}”>Register</a><br />


{/if}





I hope that this basic example demonstrates that there is a lot that you can do with these conditional variables.


Posted on November 08, 2004 at 02:33 PM in Tips
Email this entry

The trackback URL for this entry is: Trackbacks are disabled for this entry

Trackbacks:

No trackbacks yet.

Comments:

No comments yet.

Next entry: MT Gettysburg for EE

Previous entry: EE Template Contest