Moved the $status = Yii::app()->user->user($id)->status; inside the !isGuest code block so it's only called when the used is logged in.