I have a block of links, one of which is "Log In". I wish to change this to "Log Out" once the user, any user, is logged in. The easiest way I know to do this is to just have a little php code:

<?php
if (userLoggedIn) echo "Log_Out_link";
else echo
"Log_In_Link";
?>

Does such snippet of code exist? I tried searching the site but came up empty handed.

If there is a better way to do this, I would also like to know, but this way suits me just fine.

Comments

How I did it.

if($user->uid) {
echo 'click <a href="logout">here</a> to log off.';
}

Drupal 7 . . . the most commercial Drupal yet!
Drupal 7 . . . 1 2 3 3+ years in the making!

You forgot this:

global $user;

You can't call $user->uid without it.

Pobster

If you care about non clean URL support

If you care about non clean URL support it is better to construct the link with the l function (thats a lower case L). The code to print a link would then look like print l(t('logout'), 'logout');

nobody click here