Public (Guest) Access for course without any other privilege

Public (Guest) Access for course without any other privilege

by Ben Kelada -
Number of replies: 1

Hi We currently have a moodle setup with no guest access, everything else gets redirected to the login page.

We would like to enable public (guest access) to particular courses, however we still want any other access redirected to the login page.


i.e.

accessing a non guest access enabled course should go to login page (rather than message page with this course does not have guest access)

going to the site main page ( /. ) should got to login page (not site main page or my page)

guest users should not be able to browse course lists

there should be no guest login button on the homepage

All they should be able to do is go directly to a course url, and be allowed to view the content as a guest (i.e. auto logged in as guest or similar)


 All this can be done by customising different parts of moodle, i'm just wondering if this configuration is available without customisations.

The closest i can get is:

enabling guest access, auto-login for guests, enable guest login button -> this enables guest access for course but also allows users to browse main page and course pages and doesnt auto redirect to login page, also the login as guest button is displayed on the login page


disabling guest login button, means that auto login as guest doesnt work anymore and users cannot access the course as guest any more and all queries are redirected to the login page.


Any advice appreciated,

cheers,

Ben K


Average of ratings: -
In reply to Ben Kelada

Re: Public (Guest) Access for course without any other privilege

by Ben Kelada -

An update to my own message

Behaviour we are after:

i.e. moodle continues working exactly the same (restricted access to users with accounts) except public users are auto logged in as guest for courses in which guest access is enabled.

Having looked through the code i have identified a few different places which prevent the behaviour we require.

1) the config item "Guest login button" must be set to "Show" for guest access to work

I have logged this misnomer here: https://tracker.moodle.org/browse/MDL-47634

2) Once logged in as a guest user the base url "mymoodlesite.com/" will show either /my/ for guests or the site home page. 

i have made a quick customisation for our purposes on /index.php

+    /* LTU Custom Disable site page for guest users - sends them to login page*/
+    if (isloggedin() and isguestuser()) {
+        redirect(get_login_url());
+    }

3) I am now working on customising the course pages so they dont show the message "this course does not have guest access enabled" rather they forward to the login page.