How do I hide a field after login? Could anyone tell me how I can hide a field after user login? For example, at the top of my front page I have:


  login | register


However, upon successful login, I would to hide this field.  

The above 'login | register' field is just a 'div' block with 'href'.
One good example is the hiding of the default Drupal login block after login in.

I am using Drupal 7.
If you're outputting this directly in a template file it would be as simple as:

&lt;?php if (user_is_anonymous()) : ?&gt;

&lt;a href="..."&gt;login&lt;/a&gt; | &lt;a href="..."&gt;register&lt;/a&gt;

&lt;?php endif; ?&gt;


If you're using a block then you most likely won't want to put PHP code directly into it as that would involve using the evil eval() function. Instead you could add a new menu and use the block that's automatically created for that menu to output the links.

Since the menu system respects permissions, and the logged in users don't have access to the register or login page, the links simply won't show when a user is logged in.