0

I'm trying to get the reset password link into the new account mail, right after registration. My attempt right now is:

theme/template/customer/resetlink.phtml

if ($user->getId()) {
    $newResetPasswordLinkToken = Mage::helper('admin')->generateResetPasswordLinkToken();
    $user->changeResetPasswordLinkToken($newResetPasswordLinkToken);
    $user->save();

    echo "https://thisismyshop.com/customer/account/forgotpassword/?id=" . $user->getId() . "&token=" . $newResetPasswordLinkToken;

Layout handler in customer.xml

<resetlink_handle_new_account_mail>
  <block type="core/template" name="resetlink" template="customer/resetlink.phtml" />
</resetlink_handle_new_account_mail>

E-Mail Template:

 {{layout handle="resetlink_handle_new_account_mail" user=$customer}}

I can call the template via block, which works:

{{block type='core/template' area='frontend' template='customer/resetlink.phtml'}}

But I have to transmit $customer as user to the template file in order to create a new token and generate the correct reset-url.

What am I doing wrong?

Getting Error: Uncaught Error: Call to a member function getId() on null

Thank you for your help!

Is there a more straightforward possibility? Right now the token is empty, if I use the same {{}} as used in the reset password template.

0

I already found a solution by writing an observer on customer_register_success which creates the password token. If then the new account mail is sent, I use the same Link as used within the password reset mail, which then includes the token, as it has been set previously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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