0

I earlier posted question to get customer rest password via code and below code works fine:

$email='[email protected]';

$customer = Mage::getModel('customer/customer')
                ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
                ->loadByEmail($email);
$customer->sendPasswordResetConfirmationEmail();

But what if want to reset password of one of admins , how can I use above code to work ?

2 Answers 2

2

If you want to reset password then first load admin

            $collection = Mage::getResourceModel('admin/user_collection');
            /** @var $collection Mage_Admin_Model_Resource_User_Collection */
            $collection->addFieldToFilter('email', $email);
            $collection->load(false);

then send a generate password

if ($collection->getSize() > 0) {
                foreach ($collection as $item) {
                    $user = Mage::getModel('admin/user')->load($item->getId());
                    if ($user->getId()) {
                        $newResetPasswordLinkToken = Mage::helper('admin')->generateResetPasswordLinkToken();
                        $user->changeResetPasswordLinkToken($newResetPasswordLinkToken);
                        $user->save();
                        $user->sendPasswordResetConfirmationEmail();
                    }
                    break;
                }
            }
0

If u want how to work in php so u can easy to idea using see the code hear.

app\code\core\Mage\Customer\controllers\AccountController.php

public function forgotPasswordPostAction() 

U can apply your module and Overriding customer account controller.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.