Error : Call To A Member Function Isadmin() On A Non-Object


I am getting the follow error :

PHP Fatal error: Call to a member function isAdmin() on a non-object in /var/www/eduappstore/subdomains/staging/public_html/protected/views/app/admin.php on line 15

$user = Yii::app()->user->getCurrentUser();

if (!$user->isAdmin()){   // LINE 15

	$papers = Paper::model()->findAllByAttributes(array('admin'=>$user->id));

	$arr = array();

	foreach ($papers as $paper){

		$arr[] = $paper->id;



What might me the issue ?

getCurrentUser() returns ‘null’

It is advisable to put else in your if statement so that you can easily know if your IF statement was not successful.