active user based on owner

hove am i doing this wrong

trying to show if user is online from owner_block

have been playing with this for hours now and still can't get it to show result for other users 

p.s. sorry for my bad english

$user_online = get_user($guid);
if($user_online->last_action > time() - 300) {
    $body = "<div class=\"status status-online\"></div>";
    } else {
    $body = "<div class=\"status status-offline\"></div>";
}