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

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

by Zbigniew Fiedorowicz -
Number of replies: 8
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