Skip to content

Commit

Permalink
Merge pull request #10319 from kinglozzer/email-hooks
Browse files Browse the repository at this point in the history
ENH: Add extension hooks to core emails
  • Loading branch information
dhensby authored May 16, 2022
2 parents 6c3edb2 + 903dd86 commit 981f636
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Security/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,16 +914,18 @@ public function onBeforeWrite()
&& static::config()->get('notify_password_change')
&& $this->isInDB()
) {
Email::create()
$email = Email::create()
->setHTMLTemplate('SilverStripe\\Control\\Email\\ChangePasswordEmail')
->setData($this)
->setTo($this->Email)
->setSubject(_t(
__CLASS__ . '.SUBJECTPASSWORDCHANGED',
"Your password has been changed",
'Email subject'
))
->send();
));

$this->extend('updateChangedPasswordEmail', $email);
$email->send();
}

// The test on $this->ID is used for when records are initially created. Note that this only works with
Expand Down
2 changes: 2 additions & 0 deletions src/Security/MemberAuthenticator/LostPasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ protected function sendEmail($member, $token)
))
->addData('PasswordResetLink', Security::getPasswordResetLink($member, $token))
->setTo($member->Email);

$member->extend('updateForgotPasswordEmail', $email);
return $email->send();
}

Expand Down

0 comments on commit 981f636

Please sign in to comment.