Guest access without the [Login as Guest] button...

Guest access without the [Login as Guest] button...

by Ian Usher -
Number of replies: 41

Hello...

I'm using Moodle to create a repository of resources which will (hopefully) be used as an online learning environment, but it's definitely one step at a time around here.

Anyway, an obvious part of my task is to encourage people to use the resources, however we don't have a central user database (at the moment) and I'm not keen on self registration.

What I'd like to be able to do is easily allow 'Guest' access to certain courses - I know I can do that, but the issue for me is that the user has to visit the 'Login' screen click the 'Login as Guest' button. It might not seem much to those of us who regularly log in, but this might be a big step to those to whom logging in is a significant barrier, particularly if they are not convinced of the value of such a resource anyway... so to my question!...

Can I enable Guest access without the Login screen intervening? i.e. if a course is listed and has guest access, can clicking on the title of the course take me straight to it as a guest?

Am I asking for the moon and the stars?

Many TIA!

Ian.

Average of ratings: -
In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Zbigniew Fiedorowicz -
Use the guest shortcut in the url, i.e. add '&username=guest' (or '?usernamae=guest') to the url.  For example, log out of moodle.org and then go to this url:
http://moodle.org/course/view.php?id=5&username=guest
In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Ian Usher -

fantastic, thanks,  that's really useful...

now, if it could only be a per-course setting which was switchable, then I'd be a v happy man... thoughtful

In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Zbigniew Fiedorowicz -
It already is a per course setting.  Under course settings you have three options:
  1. Do not allow guests in
  2. Allow guests without the key
  3. Allow guests who have the key

In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Ian Usher -

...I'm aware of those settings, but I think what I'm after is a setting which allows me to avoid the [Login as Guest] button for a particular course. With some courses it may be desirable I suppose.

Something like a

[x] allow guests without logging in

setting, which would append the &username=guest parameter onto the URL automatically. Otherwise, I have to hand encode it for course on which I want to achieve this, and I wouldn't wish that on other users...

This would be similar to having a 'normal' CMS which allows anyone in, but allows more information once you have logged in. Moodle is (currently) different from this model since it requires you to visit the Login page and click [Login as Guest] - which is a step I'd like to leave out on certain courses which consist primarily of public information in the form of downloadable resources, etc.

In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Hans de Zwart -
I can see your point and I agree that it would be a useful setting. It should be so hard to modify this and I do not see any problematic implications (which of course does not mean there are none).

In the meanwhile you could maybe use a simple redirection script for any of the courses where you need this functionality. That way you don't have to impose it on anybody else. Or is that too easily thought?
In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Zbigniew Fiedorowicz -
The following modification to course/lib.php should do what you want. (Make a backup first, and do the editting with a text editor, not a word processor or html editor.)

In the function function print_category_info($category, $depth) change the line

echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";

to

if ($course->guest ) {
echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id&username=guest\">$course->fullname</a>";
} else {
echo "<a $linkcss href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
}
In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Raz Goren -

code has changed in 1.9x so it needs a different code now

linking the course directly works fine :
<moodle url>/course/category.php?id=<id number>1&username=guest

Raz

In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Greg Fishbone -

I like this guest shortcut idea.  Here's a followup question that should be easy enough for somebody to figure out...

If I wanted the &username=guest added to the links generated by the RSS feed of a Moodle forum, what file would I need to tweak and how?

In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Mike Chaplin -
Hi

This is very useful. In 1.8 I have found that you can also append this to the end of a category listing too eg

<moodle url>/course/category.php?id=1&username=guest

Any courses in that listing that allow guest access allow you in without making the round trip to the login page. The guest login is generated before you go into the course.

best regards

Mike Chaplin
vleadmin@mancat.ac.uk
In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Gustav W Delius -
I agree that logging in as guest seems to be a bit of an unnecessary step. In my moodle installation I therefore have a configuration variable $CFG->loginguests. If it is set to 1 then a visitor entering a course that allows guests will automatically be logged in as guest. They then have to use the "login" link at the top right to log in as someone else.

If there is no objection I would like to commit this modification. I can't see any drawback and it makes it possible to make moodle behave more like a content management systems, which is desirable for certain sites. The default behaviour of course will stay as it is at the moment.
In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Jaime Villate -
I vote in favor of that modification. The best way to convince some of my colleagues to use our Moodle site for their courses is to show them other courses already in progress. A lot of them do not bother to get in when they are presented with a login screen
(I don't blame them, I've done the same in the past with the Luvit and WebCT, sites in our university).
In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Sounds good approve - please do it - as long as it defaults to being off. Call it autologinguests.

lib/defaults.php
admin/config.html
lang/en/moodle.php

The current behaviour (of sending visitors to the login screen) is a good way to show new users that logins are necessary on this web site, but I can also see how this other way will also work well for more open sites.
In reply to Martin Dougiamas

Re: Guest access without the [Login as Guest] button...

by Gustav W Delius -
Done.
In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Ian Usher -

cool Fantastic!  approve Thank you big grin

How do I get this / add it in - I'd like the 'approved' version, but am happy to modify my own code if necessary...

... or is it in 1.3.2? thoughtful

In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Ian Usher -

...so is this in / will it be in 1.3.n or later? I really need to implement this and so would like to find out (a) the code for it and where to put it or (b) which release it's in...

Yes, I know I'm impatient...

In reply to Ian Usher

Re: Guest access without the [Login as Guest] button...

by Gustav W Delius -

It is in 1.4dev and will as far as I know be in the final release of 1.4 at the end of this month, even though I didn't actually find it to be as convenient as I had thought. The drawback is that the site is more tedious to use for registered users because they will no longer automatically be presented with the login screen when entering a course but rather have to click on "login" explicitly.

See also http://moodle.org/mod/forum/discuss.php?d=9518.

In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Zbigniew Fiedorowicz -

Why not make it a per course (rather than per site) setting, i.e. allow in guests without any login?

In reply to Zbigniew Fiedorowicz

Re: Guest access without the [Login as Guest] button...

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
That's not a bad idea ...
In reply to Martin Dougiamas

Re: Guest access without the [Login as Guest] button...

by Ian Usher -

I think that's what I suggested originally (see above)... apologies if I wasn't explicit enough. Ideally it would ideally be an option in each course on the Course Settings page - because (I don't know about you) but I have things which I don't want to be open and some which I do.

Thanks to all concerned! approve

In reply to Gustav W Delius

Re: Guest access without the [Login as Guest] button...

by Marilyn Fleming -

I run 1.4dev, and everybody logs in automatically as guest. After examining the code, I have a question. If multiple "guests" are logged in simultaneously, do they share the same session?

The other thing I [try to] do is track their activity by IP address to deduce what their interests are. If there is only one guest record in the user table, and the IP is recorded in that table, looks to me like the arrival of guest #2 changes the ip address so all of guest #1's activities might be logged to guest #2. Is that theory right?

In reply to Marilyn Fleming

Re: Guest access without the [Login as Guest] button...

by Andrea LaPlume -

Hi there,

I am using Moodle 2.0.3+ (Build: 20110701) and am very interested in having some of my courses available to guests without them having to login. 

Is this feature available in Moodle 2.0.3? If it is, can you let me know where I can find this? 

In reply to Andrea LaPlume

Re: Guest access without the [Login as Guest] button...

by Abraham Zeyohannis -

I am having the same problem. I saw solutions to the issue posted in 2004, but not for the current versions of moodle.

I am using moodle: version: 2011120501, release : 2.2.1 (Build: 20120109).

I followed all the instractions at http://docs.moodle.org/22/en/Guest_access, but could not get guest access to work.

The issue is that guests are prompted to login with user id field populated with "guest".

In reply to Abraham Zeyohannis

תשובה ל: Re: Guest access without the [Login as Guest] button...

by Miki Alliel -
Picture of Translators
Hello is there any solution to this issue for moodle 2? without clicking the guest button?
In reply to Miki Alliel

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Matt Hobbs -

Hi everyone,

Could we please have some info on how to allow guest access to our Moodle sites without needing to use the 'guest login' button on the frontpage? Most of the info in this thread is from 2004 and it seems not applicable to the latest versions of Moodle.

My particular goal is to have some parts of my Moodle site accessible just like a standard website, so that people can get an idea of what is on there without being presented with the barrier of a login screen. So:-

  • User receives a link for example to the main page of the website, or say a link to a gallery (I have the lightbox gallery plugin and created a course that uses it to hold some images)
  • User click on this link and goes straight to the content without facing a login screen

I don't mind if this is done by URL, e.g. adding &username=guest after the standard URL - this was mentioned earlier but I can't get it to work, I assume because it applied to older versions of Moodle.

Any other suggestions or workarounds as to how to accomplish the same thing would be much appreciated.

Matt

In reply to Matt Hobbs

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi Matt,

For up-to-date info on how guest access works, please see the documentation Guest access.

Guests can be logged in automatically when entering courses with guest access i.e. no login screen by ticking the 'Auto-login guests' checkbox in Administration > Site administration > Users > Permissions > User policies.

Average of ratings: Useful (3)
In reply to Helen Foster

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Emma Coles -

I have asked our Moodle Admin to switch this on but they report back "Turning on the "auto-login guests" makes the whole system unacceptably slow." Has anyone else experienced this problem? If so, was there a workaround? Many thanks (in advance). Emma

In reply to Emma Coles

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

I have never heard of that  one before - let's see what others say.

In reply to Helen Foster

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Night Owl -

I have configured all of the settings listed in this document, but I still cannot view an individual course as guest without the guest login button setting being set to show in the authentication plugin. If I turn that setting on, i can go directly to a course by adding the &username=guest extension onto the course URL, but if I turn it off it doesn't work. I don't want that turned on because I don't want anyone else to have guest access, and I don't want anyone to go to our Moodle main site URL and see anything as guest. (ie: when you go to our URL I just want the login screen).  How can I do this?

In reply to Night Owl

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Andre Paz Leal -

Somebody found a way of doing this? AUto-login set on but still the guest is returned to the login page to click the login button.

In reply to Andre Paz Leal

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Paul Nijbakker -

Bump. I also have all the settings suggested in the Documentation for Moodle 2.5 switched on (except the guest access password and the Open to Google setting), but still cannot enter any course as a guest, not even when clicking the Login as a guest button and the "&username=guest" addition to the course URL does not work either.

Yet it must be possible to allow guest access without passing via a login page, because this Moodle.org site allows just that.

Rgrds,
Paul.

In reply to Paul Nijbakker

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Paul Nijbakker -

Hi,

I tried to follow these instructions found elsewhere in the forums:

  1. Login to your database in PHPMyAdmin
  2. On the lefthand side, scroll down and click on the little icon (not the text) for mdl_user (the icon or the text makes no difference in my case; the view is the same)
  3. This will open a table, where the top entry in the "username" column is "guest". Click on the pencil icon on the lefthand side. (Interestingly, I did not find any user with the username "guest" in my Moodle database, but I find no fewer than 41 users that have coded usernames and whose firstname is "Guest User". Is that normal?)
  4. This will open another table. On the sixth or so entry from the top is a row with "mnethostid" in the "field" category. Change its value to "0", then scroll to the bottom of the page and click "Go". That's it. (Changing the setting mnethostid to "0" for all the "guest User"s did not have any result in my case.)

In my other Moodle 2.5 installation there is a user (id = 1) that has the username "guest". I changed the coded username for id = 1 in my former installation to "guest", but that did not help either. Even if I also change the password of the "guest" account to "guest" and I try logging in normally as "guest/guest" I cannot get in.

I also tried combining the Guest enrolment in a course with a Self-enrolment for the Guest role, without an enrolment key... nada. I keep getting returned to the login page where clicking the Login as a guest button just puts the username "guest" in the username box, clicking it again, results in "Invalid login, please try again".

Who would have any suggestions?

Rgrds,
Paul

In reply to Paul Nijbakker

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Paul Nijbakker -

I also tried taking away the password for the "guest" ID altogether, but the site just keeps refusing any kind of guest access.

Happy Valentine's Day sad

Paul.

In reply to Paul Nijbakker

Re: Guest access without the [Login as Guest] button...

by Paul Nijbakker -

Hi all,

We finally got guest login working again, by opening the mdl_user table in the database and returning the id=1 user to username = "guest" with as password "guest" (We used a random user to change the password to guest and then in the database we copied that salted password to the Guest User ID.)

We also changed the "1" under Deleted to "0" (As it appeared Moodle had been removing and recreating the Guest User in the past).

Then we opened the mdl_config table in the database and changed the siteguest value to "1".

And then we Purged all cache.

And then it started working again normally (before this the guest ID was treated as a normal user by Moodle (i.e. it could edit its profile and post in forums etc.) So, issue fixed, solution and solved (in case someone is searching wih these words as search terms wink).

Rgrds,
Paul.

In reply to Paul Nijbakker

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Barbara Taylor -

Paul,

I put guest courses into a guest category.  The course is set to be visible and guest access yes.  When I go to my site -> click on the Courses link in the Navigation block -> I see the Guest category -> click on one of the courses listed -> have instant access

 

Barbara

In reply to Barbara Taylor

Re: Guest access without the [Login as Guest] button...

by Paul Nijbakker -

Hi Barbara,

Thank you for your response but it does not address my problem. My site does not allow guest access at all, despite all the right settings being in place. I suspect the system was corrupted at some time, but my attempts to fix it have been fruitless.

Rgrds,
Paul.

In reply to Helen Foster

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Trevor Wood -

Trying this now. yes you can set this option but the Guest login button still has to be there.

So if a user has a direct link to X course go straight in, bypassing login screen, but those who go to login page will still see guest login button.


Would be nice to hide that because users who do login from homepage can't really do much (presented with a whole bunch of courses that are inaccessible).

In reply to Trevor Wood

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Dave Perry -
Picture of Testers

The lack of '&username=guest' working is a real pain for some of our pages (e.g. college documents, which needs to be accessible by students who haven't got their moodle access yet). Are there plans to re-instate it?

In reply to Dave Perry

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Mitchell Kennard -
I would also appreciate something like this. I am trying to open up a particular course to non account holders without them having to click on 'Log in as guest.' I have turned on auto-login for guest, and that works fine. The problem is that anytime a user clicks on a link to any other course on the site (e.g., a post link from a post email), the system logs them in as guest and says that guests do not have access to that course. They then have to login to the system, go back to the email, and then click on the link. That is far too much trouble for everyone on the site. Being able to modify a single link with '&username=guest' would resolve the issue.


Any suggestions?

Thanks,

Mitchell

In reply to Mitchell Kennard

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by srinu g -

In Settings > Site administration > Users > Permissions > User policies, you can tick the box so that visitors are automatically logged in as guests when accessing a course with guest access (i.e. they don't have to click the "login as guest button".

In reply to srinu g

Re: תשובה ל: Re: Guest access without the [Login as Guest] button...

by Dave Perry -
Picture of Testers

The problem on our site (2.9) is that this setting means it does this for EVERY page even if you don't have guest logins enabled on the page. Which is a bug to me, but would like someone to confirm this before I file it as one officially.

If guest logins aren't enabled on a page, it should force a proper login for any page that uses the require login function.