WebUser.getId Not Defined

Hi,

We are authenticating users via the database and have a user controller class with the following function:


public function actionProfile($id=''){        


			$user = Users::model()->find('username=?', array(

					Yii::app()->user->getId));       

//			if (Yii::app()->user->id)	

//            	$user = Users::model()->find('username=:username', array(

//            		':username'=>Yii::app()->user->id)

//            );            	

            if(!$id){

                $id = $user->id;

                if(!$id)

                $this->redirect('login');

            }

            if( getUserSess('user_type') == 'Sitter') {

                $this->render('profile_detail', array('user_id' => $id ));

            } else {

                $this->render('petowner_profile_detail',array(

			'model'=>$this->loadModel($id),

		));

            }

        }

In /protected/componentns, I have created a WebUser class as follows:


<?php

class WebUser extends CWebUser{

	private $_model;

	

	function getId(){

		$user = $this->loadUser(Yii::app()->user->id);

		return $user->id;

	}

	

	protected function loadUser($id=null){

		if($this->_model===null)

		{

			if($id!==null)

			{

				$this->_model=Users::model()->findByPk($id);

			}

			return $this->_model;

		}		

	}

}

The profiledeai view is as follows:


<?php

    if(!$user_id){

        $user_id = getUserSess('id');

    }

    $this->widget('ext.UserProfile.BasicProfile',array('user_id'=>$user_id)); ?>

    <?php //$this->widget('ext.UserProfile.UserServices',array('user_id'=>$user_id)); ?>

When we attempt to view a user profile on the server, the error WebUser.getId not defined is given. How can we remedy this issue?

it’s either


// http://www.yiiframework.com/doc/api/1.1/CWebUser#getId-detail

Yii::app()->user->getId()

or


// http://www.yiiframework.com/doc/api/1.1/CWebUser#id-detail

Yii::app()->user->id