Change Customer Login Password in Magento

Viewed 11157

I want to Change Login Password of a customer in Magento, I Uses the below Code to Update the Password But It doesn't work for me

 $customerid = 46;
 $oldpassword = 12345678;
 $newpassword = 87654321;
 $customer = Mage::getModel('customer/customer')->load($customerid);
 $passwordhash = $customer['password_hash'];
 $phasharray = explode(":",$passwordhash);
 $passpostfix = $phasharray[1];
 $completeOldPassword =  $oldpassword.":".$passpostfix;
 if($completeOldPassword==$passwordhash){
    $customer->setPassword($newpassword);
    $customer->save();
 }
4 Answers
Related