Trying to make a custom region disappear upon user login, then reappear when user logs out I've looked everywhere for an answer to my problem, but can't find one. My goal is to collapse/force a custom region on my website to disappear when a user logs in, and then have it reappear when the user logs out.  Or, if it's not possible to collapse a region, to replace the region with an empty region that, through CSS, I have styled to display with zero height. Basically, I'm trying to make a custom region disappear upon user login, and then make it so the region reappears when the user logs out.

The reason for this is I'm putting the final touches on transforming the login block on my website so that instead of appearing in the sidebar, it appears as a horizontal login bar. I'm 90% of the way there. I created a custom region at the very top of the page to house the bar, and the bar kind of looks like the horizontal login bar you see on Facebook. But in reformatting the login block using CSS, I was only able to achieve the look I wanted by forcing the "Forgot your password?" and "Create a new account" links not to appear (otherwise, the links would reside between the password field and the "Log in" button, which looked weird). 

But that left me with no login help links. To try to resolve this problem, I created a new region directly under the "username" and "password" fields to house the "Forgot your password?" and "Create a new account" links, which displays really nicely. But, of course, whenever someone logs in, those links remain on the screen, which is obviously weird. 

I need to figure out a way to make the new region disappear when the user logs in, and to reappear when the user logs out. Also, I want the other regions in the header directly below the two new custom regions to move up once the region disappears so that there's not a gaping hole in the space where the region used to be. I'm pretty new to PHP, so what I've tried may be way wrong, but this is what I attempted, which didn't work -- it's the option of trying to swap out the region with the links with the empty region when a user logs in:

     &lt;?php 
        if(isset($username) == false):
        print render($page['nameofregion1']);
        else: ?&gt;&lt;/div&gt;
        &lt;div id="region2style"&gt;
        &lt;?php print render($page['nameofregion2']);
        endif;
     ?&gt;


where the CSS for 'region2style' is set to "height: 0px" to give it zero height. My suspicion is that I'm misusing the variable $user here, among other errors, but I can't seem to figure out what variable holds username info in Drupal. I'm sure there's a more elegant way of doing this, and if someone could point me in the right direction, I'd really appreciate it. Thank you.
Context is a great plugin for remodelling sections of your website - paired with Delta and the Omega theme, you can overhaul your entire layout based on nearly any condition without editing any code by hand.

There's a decent intro tutorial for Context and Delta over here.

But if that doesn't fit the bill, you're on the right track with your .tpl.php files. Checking for user login is quick, just remember to global the variable first:

&lt;?php
global $user;

if ( $user-&gt;uid ) {
  // Logged in user
}
else {
  // Not logged in
}
?&gt;


... and by inserting the desired code between braces you could easily toggle blocks, regions, messages and nearly anything else accessible from the template.

This is my "PRINT ALL THE THINGS!!" snippet, try it out for the $user variable:

&lt;?php global $user; echo '&lt;pre&gt;'.print_r($user, true).'&lt;/pre&gt;'; ?&gt;


Good luck!