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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

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


Go to End


3 Posts   1470 Views

Avatar
tfliam

Community Member, 20 Posts

14 March 2012 at 2:37am

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

Forum Moderator, 5523 Posts

14 March 2012 at 10:05pm

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

Community Member, 20 Posts

15 March 2012 at 2:30am

Hi Willr,

It works perfectly fine, thanks!