3

I am user #1; I do have the PHP filter module enabled, but still my block is displaying, when I'd like it to be hidden. Here's my implementation of hook_block_info:

/**
 * Implements hook_block_info().
 */
function alerts_block_info() {
    $blocks['get_e_mail_alerts'] = array(
        'info' => t('Get e-mail alerts'),
        'status' => TRUE,
        'region' => 'sidebar_first',
        'weight' => 0,
        'visibility' => BLOCK_VISIBILITY_PHP,
        'pages' => '<?php global $user; if ($user->uid == 1) { return FALSE; } else { return TRUE; } ?>',
    );
    return $blocks;
}

Thanks.

8
  • Try using the English spelling of "visibility". You currently seem to have gone for something a bit more fancy in your array keys ;)
    – Clive
    Oct 1, 2013 at 14:34
  • I would have bet my mortgage that was going to work, but it didn't. I cleared all my caches also?
    – dbj44
    Oct 1, 2013 at 14:39
  • Do you know if the PHP code gets ran?
    – Steven
    Oct 1, 2013 at 14:49
  • How can I determine that?
    – dbj44
    Oct 1, 2013 at 15:01
  • @user1919784 Quickest way to check - chuck die("it's running"); in the pages var and reload a page with the block on
    – Clive
    Oct 1, 2013 at 15:05

1 Answer 1

1

I put this in my php code and it works just right:

<?php drupal_set_message("here"); global $user; if ($user->uid == 1) { return 0; } else { return 1; } ?>

The drupal_set_message is called and everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.