diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php
index bd8dec262d3..697724ac123 100644
--- a/blocks/online_users/block_online_users.php
+++ b/blocks/online_users/block_online_users.php
@@ -97,7 +97,8 @@ class block_online_users extends block_base {
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
$this->content->text .= print_user_picture($user->id, $COURSE->id, $user->picture, 16, true).' ';
$this->content->text .= ''.$user->fullname.'';
- if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and !isguest()) { // Only when logged in
+ if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and
+ !isguest() and $user->username != 'guest') { // Only when logged in and messaging active etc
$this->content->text .= "\n".' '
.'
';
}