diff --git a/user/lib.php b/user/lib.php
index de31c6c7d47..36b3be61973 100644
--- a/user/lib.php
+++ b/user/lib.php
@@ -189,7 +189,9 @@ function print_user($user, $course, $string, $countries) {
if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category) or isteacher($course->id)) {
echo "$string->email: email\">$user->email
";
}
- echo "$string->location: $user->city, ".$countries["$user->country"]."
";
+ if ($user->city or $user->country) {
+ echo "$string->location: $user->city, ".$countries["$user->country"]."
";
+ }
if ($user->lastaccess) {
echo "$string->lastaccess: ".userdate($user->lastaccess);
echo "  (".format_time(time() - $user->lastaccess, $string).")";