I have done as per your suggestion but i am getting "Error 400 Your request is invalid".
Find below the steps and code
My model controller
public function actionChangepassword($id)
{
$model=$this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Customer']))
{
$model->attributes=$_POST['Customer'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('Changepassword',array(
'model'=>$model,
));
}
Allowed the changepassword for authenticated users.
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update', 'changepassword'),
'users'=>array('@'),
public function actionChangeProfile($id)
{
$model=$this->loadModel($id);
$oldPassword=$model->password;//Capture the old password.
$model->password='';//Make this empty.else the hashed password appears as string of dots in form field.
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->password=="")
$model->password=$oldPassword;
else $model->password=md5($model->password);//customize the encrypting logic in your own way.You can put some additional salt.
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}
create a link in your view.
echo chtml::link(CHtml::encode('Change Your Profile'),array('changeProfile','id'=>$model->id));
Make permission in Controller
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('create','update', 'changeProfile'),
'users'=>array('@'),
I am now able to change the password but i am seeing the existing password in hash format, so kindly let me know how to remove the existing hash of the password and keep the field blank.
I am now redirecting the user to the view the profile with the below code from sitecontroller in actionlogin. I want to create a menu call profile and on clicking that link his profile should be shown.
I am now redirecting the user to the view the profile with the below code from sitecontroller in actionlogin. I want to create a menu call profile and on clicking that link his profile should be shown
you dont have to do a redirect you can just simply add the link to you customer/view/id action since you profile only will be displayed when user is logged in
Now i am concern with the url it shows the id of the user at the end “/customerwebsite/index.php/customer/view/id/37” if the user changes id from 37 to 38 he goes in another user’s profile. is there any way to avoid this, also i want to show “/customerwebsite/index.php/profile” in the url.
I tried using url manager but not succeded. find below the code