How to disable a block for guest or not logged

How to disable a block for guest or not logged

by haz sam -
Number of replies: 2
Hi,
I would like to disable thre display of a block if the user is not logged or if it's a guest.

How can I do that?

thanks
Average of ratings: -
In reply to haz sam

Re: How to disable a block for guest or not logged

by Mat Cannings -

I am not sure if this is exactly what you are after.

A while back I modified the HTML block so that it would only appear if you are an admin user (http://moodle.org/mod/forum/discuss.php?d=26951). I have just modified this so that it only appears if you are logged in and not a guest.

The line of code below is the check that is being used

if (isloggedin() && !isguest())

 
In reply to Mat Cannings

Re: How to disable a block for guest or not logged

by Red Morris -

Use something like this and it should work:

if (isloggedin() && !isguest()) {
   $this->content->text = 'fgdfgdgdgdfgdfg';
} else {
   $this->content->text = '';
}

If the content is blank Moodle won't show the block