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.