Hi,
Moodle Version 3.5.2
I'm creating a comments plugin where there is a text box at the top of the page and then underneath that are all the previous messages from users. When a user fills in the text box and clicks submit, it adds the data to the database and then refreshes the page, adding the message to the page.
The problem I have is when i submit the forum it can't then get the moduleID or courseID to come with it . The code I have is
if ($mform->is_cancelled()) {
redirect(new moodle_url('/mod/comments/view.php', array('id' => $cm->id)));
} else if($fromform = $mform->get_data()) {
$todb = new stdClass();
$todb->commentsid = $cm->id;
$todb->userid = $USER->id;
$todb->created = time();
$todb->message = $fromform->posting;
$todb->deleted = 0;
//print_r($todb);
$DB->insert_record('comments_posts', $todb);
redirect(new moodle_url('/mod/comments/view.php', array('id' => $cm->id)));
};
Can anyone help?
Thanks
Kieran