Login/logout in header or in auto-nav

Permalink 1 user found helpful
Is it possible to insert a link for login and/or logout in the header banner or autonav bar but have it detect whether or not the user is logged in so it displays the correct link? What would be the code and where would I paste it? I appreciate your input.

View Replies:
mojoburns replied on at Permalink Reply
mojoburns
Would also like to do this, did you find a way? cheers
Mnkras replied on at Permalink Reply
Mnkras
<?
         $u = new User();
         if ($u->isRegistered()) { ?>
            <? 
            if (Config::get("ENABLE_USER_PROFILES")) {
               $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>';
            } else {
               $userName = $u->getUserName();
            }
            ?>
            <?=t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?=$this->url('/login', 'logout')?>"><?=t('Sign Out')?></a>
         <? } else { ?>
            <a href="<?=$this->url('/login')?>"><?=t('Sign In')?></a>
         <? } ?>
admin replied on at Permalink Reply
Where does this code go?
wvanelten replied on at Permalink Reply
Don't know about his code,
But I used this:

$u = new User();
         if($u->isLoggedIn()){
if (Config::get("ENABLE_USER_PROFILES")) {
               $userName = '<a href="' . $this->url('/profile') . '">' . $u->getUserName() . '</a>';
            } else {
               $userName = $u->getUserName();
            }
echo('Hello ');
echo $userName;
echo(' || <a href="' . $this->url('/login/logout') . '">Log Out</a>');
         }else{
            echo('<a href="' . $this->url('/login') . '">Log In</a>');
         }


And pasted it in this easy block.http://www.concrete5.org/marketplace/addons/simple-php-block/...