diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a6cb7004e8c..b2416c670b7 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -736,7 +736,7 @@ function set_user_preference($name, $value, $otheruser=NULL) { if ($preference = get_record('user_preferences', 'userid', $userid, 'name', $name)) { if (set_field('user_preferences', 'value', $value, 'id', $preference->id)) { - if (empty($otheruser) and !empty($USER)) { + if ($userid == $USER->id) { $USER->preference[$name] = $value; } return true; @@ -749,7 +749,7 @@ function set_user_preference($name, $value, $otheruser=NULL) { $preference->name = $name; $preference->value = (string)$value; if (insert_record('user_preferences', $preference)) { - if (empty($otheruser) and !empty($USER)) { + if ($userid == $USER->id) { $USER->preference[$name] = $value; } return true;