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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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   1270 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!