1

i want to create reset password link and mail it to customer using php code what have i to write to do this could not figure out ?..

i wrote below code in my custom page but it not works:

$email='[email protected]';

$customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email);
$newResetPasswordLinkToken =  $customer->_getHelper('customer')->generateResetPasswordLinkToken();
echo $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
$customer->sendPasswordResetConfirmationEmail();
2
  • Where are you running this code from? Commented Oct 13, 2014 at 18:54
  • i have made custom layout page for that
    – mcoder
    Commented Oct 14, 2014 at 1:19

2 Answers 2

0

To send a rest link by email

$email='[email protected]';

$customer = Mage::getModel('customer/customer')
                    ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
                    ->loadByEmail($email);
$customer->sendPasswordResetConfirmationEmail();
6
  • no i just want to create reset password link after that magento will take care : i write below code in custom page but it is not working $email='[email protected]'; $customer = Mage::getModel('customer/customer')->setWebsiteId(Mage::app()->getStore()->getWebsiteId())->loadByEmail($email); $newResetPasswordLinkToken = $customer->_getHelper('customer')->generateResetPasswordLinkToken(); echo $customer->changeResetPasswordLinkToken($newResetPasswordLinkToken); $customer->sendPasswordResetConfirmationEmail();
    – mcoder
    Commented Oct 13, 2014 at 18:47
  • thanks its working, but how can i get password reset link like abc.com/customer/account/resetpassword/… or i want to use different email template is that possible
    – mcoder
    Commented Oct 14, 2014 at 1:25
  • Not sure I understand your question, can you explain what your tying to accomplish? Commented Oct 14, 2014 at 13:26
  • but what if want to reset password of one of admins , how can i use above code to work ?..
    – mcoder
    Commented Oct 14, 2014 at 23:17
  • Take a look at orgotpasswordAction() in app/code/core/Mage/Adminhtml/controllers/IndexController.php Commented Oct 15, 2014 at 13:18
0

could you explain your use-case in more detail and where you put your code? Otherwise it is hard to help.

Thanks.

4
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation.
    – Marius
    Commented Oct 13, 2014 at 20:23
  • I was actually asking for more information, it is not clear what the the question is about.
    – RobM84
    Commented Oct 13, 2014 at 20:31
  • The answers section is reserved for answers. Do not ask questions in the answer section. Take a tour of SE to see how things should work in here.
    – Marius
    Commented Oct 13, 2014 at 20:38
  • "Use comments to ask for more information or clarify a question or answer." => got it "You can always comment on your own questions and answers. Once you earn 50 reputation, you can comment on anybody's post." => So I couldn't ask, my reputation is 29 :( So it's better to wait and not ask for more information?
    – RobM84
    Commented Oct 13, 2014 at 20:49

Your Answer

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

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