How to send notification with new password to user after password change

From aMember Pro Documentation
Jump to: navigation, search

Add this code to /amember/application/configs/site.php


<?php

Am_Di::getInstance()->hook->add(Am_Event::SET_PASSWORD, 'siteSetPassword');
function siteSetPassword(Am_Event_SetPassword $event)
{
    $user = $event->getUser();
    $pass = $event->getPassword();

    $mail = Am_Di::getInstance()->mail;

    $mail->setFromToDefaultFrom();
    $mail->addTo($user->email, $user->getName());
    $mail->setBodyText(<<<CUT

Hello, {$user->getName()}

Your new password is {$pass}

CUT
        );
        
    $mail->send();
}