Allow Guest access to a Forum on only the front page

Allow Guest access to a Forum on only the front page

by SELF Management -
Number of replies: 12
I have searched but could not find a way to allow guests to participate in the forum on the front page. Is there a way to do this without rewriting code?

The idea is to let guests post questions or concerns in an open dialog before full enrolment. Kind of like a student counseling session.
Average of ratings: -
In reply to SELF Management

Re: Allow Guest access to a Forum on only the front page

by Timothy Takemoto -

Dear SELF Management
Not as far as I know. I do exactly this - allow guest access to a help forum - by rewriting the code.

Change mod/forum/post.php just to allow guest access to the top page, but not to other forums.

// Takemoto added the "$course->id > 1 &&" to the next line to allow guest access to forums on the site page.

   if ($course->id>1 && isguest()) {

There is even a way of allowing guests into quizes too -
http://moodle.org/mod/forum/discuss.php?d=42916#200539
Timothy
In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by SELF Management -

Tim, I thank you and will attempt to install code in a help forum.

Also grateful for the quiz link but it is much to advanced for me. 

In reply to SELF Management

Re: Allow Guest access to a Forum on only the front page

by Timothy Takemoto -

My pleasure. The quiz thing involves making changes to the database. Lets hope it is integrated sometime soonish.
Tim

In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by SELF Management -
Tim, not trying to sound like a total dolt (i am) there are 2 things i need help on.
1. where do i place that code? and 2. how do I edit the post.php file?
i can get to it but edit it!?

i really am new to this.
In reply to SELF Management

Re: Allow Guest access to a Forum on only the front page

by Timothy Takemoto -

Dear SELF

It is really easy.
1) Find the file "post.php" in moodle/mod/forum/, in the distribution that you uploaded to your server, or just download it from your server.
2) Open it in a text editor. Notepad is not very good because it does not preserve the line breaks. I use a Japanese text editor called "Sakura," because I have to use Japanese sometimes but there are lots of free text editors out there. I tried XEmacs but it was too slow to upload. I am unistalling it now.
3) Search the file for 
if (isguest()) {
4) Replace it with 
if ($course->id>1 && isguest()) {
5) Save the file
6) Change the name of the file on your server to auld_post.php in case the change does not work.
7) Upload your changed file.
8) Upload your changed file and test it by logging in as a guest. If it does not work delete it and change auld_post.php back to post.php and scratch your head.

Tim

In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by B. Gültekin Çetiner -

Thanks a lot for the tip. I want to ask another thing. I want the guest students to be able to search all forums from front site. It works currently for only admin user. The guest and even students in courses cannot search from the front page.

Thanks in advance

In reply to B. Gültekin Çetiner

Re: Allow Guest access to a Forum on only the front page

by Timothy Takemoto -
I just added a forum search page to the moodle I have installed on my desktop and found that I am able to search as a student. Can this be some sort of setting?

When you say it works only for the admin user, do you mean that other users can search, but it does not work, or that the search block does not appear, or what?

Hmm...I guess that if the content searched (or "hit") is in courses that are not open to guests or to which the student is not a member then those hits will not be shown. Do you want guests to be able to see content from courses that are not open to guests? Do you want students to be able to see content from courses that they are not a member of and are not open to guests?
In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by B. Gültekin Çetiner -

Even the users cannot search from the first site although they are registered with many courses. I have allowed guests to login automatically and I want the the guest user being able to search from the front site without logging in.

When I make a search with the guest user (user id=1) with the following http://www.mysdomain.com/mod/forum/search.php?id=1&search=string

it brings if there is anything in the front site forums. However, when I change the 'id=1' to 'id=2' manually, it brings the correct results with the guest login. The content of the course is open to guests. They can login without any problem.

I want the guests to be able to search all forums which exist in courses where guest login is allowed. I think a hack is needed for the front site in mod/forum/search.php. As stated earlier, when we give id=2, it brings the correct results. I have played with SQL by registering the guest (id=1) in all courses, but it did not solve problem.

Thanks a lot.

In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by Erlyn Baack -

Check the Alleycode editor at http://www.alleycode.com/.  It's free and lightweight. 

Some of the Moodle files are over 1000 lines long, but with the line numbering in Alleycode, it's easy to be precise either giving or following instructions on file editing.

In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by SELF Management -

Tim - i would like to further extend my gratitude to you. Code works like a charm. You have been most kind in sharing and gracious for not reafirming my ineptitude. But I still have to scratch my head and wonder why I couldn't remember how to edit the file (did it a whle back for theme). 

Hope that there is something I can share to repay in kind.

In reply to Timothy Takemoto

Re: Allow Guest access to a Forum on only the front page

by Erlyn Baack -

Hi Timothy,

Just to let you know, I tried your "code change" in 1.5.3+ on localhost (allowing guest access to forums on the front page), and it's an impressive little rewrite! wink 

Thanks!

Erlyn 

In reply to Erlyn Baack

Re: Allow Guest access to a Forum on only the front page

by Timothy Takemoto -
Glad to be of help Erlyn
If you have other little things like this I may be able to help.  I hack often.