Hiya All
I have recently, made a very small hack, to block forum access completely to guests. It works fine web resources etc, I have added a checkbox, and presents the user with a login screen as intended, and updates the field I added nicely.
Now the problem is when I have done the editing on the forum module lib.php. I have put in placement the update code for the change of value, however it is not blocking to guests! I wondered if someone could kindly just look at my small part of code, to make sure it is correct. It updates the field in mdl_forum fine but guests can still gain access...!
The code is as follows: (Extract from lib.php - under forum mod)
/// STANDARD FUNCTIONS /////////////////////////////////////////////////////////// function forum_add_instance($forum) { global $CFG; $forum->timemodified = time(); if (!$forum->userating) { if (!empty($forum->ratingtime)) { if (! $forum->id = insert_record('forum', $forum)) { if ($forum->type == 'single') { // Create related discussion. if (! forum_add_discussion($discussion, $discussion->intro)) { if ($forum->forcesubscribe == FORUM_INITIALSUBSCRIBE) { // all users should be subscribed initially
$forum->timemodified = time(); if (empty($forum->userating)) { if (!empty($forum->ratingtime)) { $post->subject = $forum->name; if (! update_record('forum_posts', $post)) { $discussion->name = $forum->name; if (! update_record('forum_discussions', $discussion)) { return update_record('forum', $forum); function forum_delete_instance($id) { |
Hope someone can help, sorry its slightly long winded the two parts of code are:
if ($forum->blockguests == 1) {
require_login($course->id);
if (isguest($USER->id)) {
error(get_string('guestsno', 'forum').".");
}
}
if (isset($forum->blockguests)) {
$forum ->blockguests = 1;
} else {
$forum->blockguests = 0;
}
Many Thanks, I am just stumped! - BTW I am not an expert on php coding, just a newbie.
Josh