From wiki.ucalgary.ca
Jump to: navigation, search

How to have Blocks visible only for anonymous (or logged in) users

Each block in Drupal can have settings to control the visibility of that block. This setting is stored at admin/block/configure/menu/MENU_ID (where MENU_ID is the menu for the block to be affected).

Under "Custom Visibility Settings" select the following option:

Users cannot control whether or not they see this block.

Under "Page specific visibility settings" select the following option:

Show if the following PHP code returns TRUE (PHP-mode, experts only).

In the Pages: textarea, paste this code, which will show a block only to anonymous users:

    global $user;
    if (!$user->uid) {
        return true;
    } else {
        return false;

This is useful for things like links to create an account, etc... To reverse this, and have a block available only to logged in users, swap the "false" and "true" return values.

Links for more info:

What to do if the Edit form displays waaay down the page (beneath the sidebar)

It's a conflict with the default Drupal stylesheet. Just drop this style into your theme's stylesheet, and you should be good to go.

.node-form .standard {
  clear: none !important;