how to hide 'Courses' block before logged in

how to hide 'Courses' block before logged in

per shefali mittal,
Number of replies: 4

Hi All,

I am using Moodle version 1.9.

I want to hide my courses block intially before user logged in. It should appear after the user logged in.

If anyone know the solution, please help me.

Many Thanks,
Shefali

Average of ratings: -
In reply to shefali mittal

Re: how to hide 'Courses' block before logged in

per John White,
Shefali,

I presume you have already changed Front Page Settings pre-logon to none,none,none,none.

If you want to keep the courses block on the front page, but only show this post-loggon edit the file...

blocks/course_list/block_course_list.php

...find the lines...

function get_content() {
global $THEME, $CFG, $USER;

...and immediately next add...

if (!isloggedin()) {
return NULL;
}

Save and test well!

Regards,

John



In reply to shefali mittal

Re: how to hide 'Courses' block before logged in

per Shane Elliott,
Avatar Core developers Avatar Plugin developers
Hi Shefali,

You can also use the roles in moodle to achieve a similar result:
1. Turn editing on;
2. Click on the "Assign Roles" icon on the block (roles)
3. Click the "Override Permissions" tab
4. Click "Guest"
5. Choose "Prevent" for the "View Block" capability

This is different from John's suggestion in that it will only affect this instance of the block whereas changing the code will affect all instances of the block. So just choose the solution that works best for you.

Cheers,
Shane.
In reply to shefali mittal

Re: how to hide 'Courses' block before logged in

per Patrick Malley,
Or ( to completely overwhelm you with options), add the following to a .css file:

.notloggedin .block_course_list {
display:none;
}