Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

How to change the 'Subject' of the default passwordreset email template?


Reply

3 Posts   605 Views

Avatar
tfliam

14 March 2012 at 2:37am Community Member, 20 Posts

Hi,

Is that possible to change the 'Subject' of the default passwordreset email template without touching the original code?

I found the code reside in Sapphire/Security/Member.php as show below:

/**
* Class used as template to send the forgot password email
* @package sapphire
* @subpackage security
*/
class Member_ForgotPasswordEmail extends Email {
protected $from = ''; // setting a blank from address uses the site's default administrator email
protected $subject = '';
protected $ss_template = 'ForgotPasswordEmail';

function __construct() {
      parent::__construct();
   $this->subject = _t('Member.SUBJECTPASSWORDRESET', "Your password reset link", PR_MEDIUM, 'Email subject');
}
}

Avatar
Willr

14 March 2012 at 10:05pm Forum Moderator, 5511 Posts

You can create your own custom Member_ForgotPasswordEmail and tell to use your class.

..

class MyMember_ForgotPasswordEmail extends Member_ForgotPasswordEmail {

function __construct() {
parent::__construct();

$this->subject = "Hi!";
}
}
..

In your _config.php

Object::useCustomClass('Member_ForgotPasswordEmail', 'MyMember_ForgotPasswordEmail');

Avatar
tfliam

15 March 2012 at 2:30am Community Member, 20 Posts

Hi Willr,

It works perfectly fine, thanks!