hiding login block was user is logged in???

Permalink
i would like to hide the login block once the user is logged in. how do i do this? thanks in advance.

michael.bruno81@gmail.com

MichaelBruno
 
CodeOtaku replied on at Permalink Reply
CodeOtaku
This code may be of help:

<?php
    $u = new User();
    if ($u->isRegistered()) {
        $userName = $u->getUserName();
        echo t('Currently logged in as <b>%s</b>.', $userName)?> <a href="<?php echo $this->url('/login', 'logout')?>"><?php echo t('Sign Out')?></a>
    <?php } else { ?>
        <a href="<?=$this->url('/login')?>"><?php echo t('Sign In')?></a>
    <?php } ?>

It's based on what I discovered in the developer docs so code from the community. I'm using this code and it works nicely.
Mnkras replied on at Permalink Reply
Mnkras
also take a look at the guest views addon (free)
MichaelBruno replied on at Permalink Reply
MichaelBruno
thanks so much! where do i put this code? in what file? what directory?
Mnkras replied on at Permalink Best Answer Reply
Mnkras
just look at the guest views addon, this is for the login block correct?
MichaelBruno replied on at Permalink Reply
MichaelBruno
if i install the addon will it change anything i currently have on the site?
Mnkras replied on at Permalink Reply
Mnkras
no it will not, if you want to hide something only for people who are logged in, click on the block then custom templates
MichaelBruno replied on at Permalink Reply
MichaelBruno
it worked well on the log in box, but i tried to use it on a box with 2 a href links and they still show. i set the box the same way as i did the other one. im not sure why it works in one case and not the other. do you know?
CodeOtaku replied on at Permalink Reply
CodeOtaku
I put the code in the default.php file of the theme.

Also, I might add that this forum area is for PHP Developers. Advice on using existing blocks should go in the "Editing with concrete5" I think. If you don't understand the basics of PHP then you are an editor.
Mnkras replied on at Permalink Reply
Mnkras
where in the default.php did you put it?
cjramki replied on at Permalink Reply
cjramki
Thanks... It is very much helped...