Develop a block to only be viewable by Admins

Develop a block to only be viewable by Admins

by David North -
Number of replies: 2

I'm developing a block. It is specifically for Admins. Therefore students etc. should not be able to view the block.

Is there a way, in the code of the block to set this functionality? 

I want the block to be a simple install and it works as its intended, and the Admins will not have to configure any settings etc. after the block has been installed.

Average of ratings: -
In reply to David North

Re: Develop a block to only be viewable by Admins

by David North -
I figured it out. It was actually very simple.


In the get_content() function in the block_blockname.php file. if this function returns nothing then the block does not display. So a simple:

if (!is_siteadmin()){return;}

does the trick.