Community & Support

setting block visibility within the .module file

I am writing a module that has a block that I want only visible to logged in users. I've found many ways of doing this by going to the configuration page of the block, but none describing how to hard code a default display into the .module file. Anyone know? I figure it's probably just an entry in the array that gets returned from hook_block, but I don't know what it's called.

Comments

Empty $block['content']

Simply keep $block['content'] empty or return an empty array when $op is 'view'. Doing so when $user->uid == 0 will prevent your block from showing up for anonymous users.
--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.

nobody click here