// Check that the user has agreed to a site policy if there is one
if (!empty($CFG->sitepolicy)) {
if (!$USER->policyagreed) {
+ $SESSION->wantsurl = $FULLME;
redirect($CFG->wwwroot .'/user/policy.php');
die;
}
}
if ($agree == 1 and confirm_sesskey()) { // User has agreed
- if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
- error('Could not save your agreement');
+ if ($USER->username != 'guest') { // Don't remember guests
+ if (!set_field('user', 'policyagreed', 1, 'id', $USER->id)) {
+ error('Could not save your agreement');
+ }
}
$USER->policyagreed = 1;
- redirect($CFG->wwwroot);
+
+ if (!empty($SESSION->wantsurl)) {
+ $wantsurl = $SESSION->wantsurl;
+ unset($SESSION->wantsurl);
+ redirect($wantsurl);
+ } else {
+ redirect($CFG->wwwroot.'/');
+ }
exit;
}