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.

Data Model Questions /

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

Auto email user when password is changed.


Go to End


1096 Views

Avatar
luuk

Community Member, 15 Posts

28 November 2014 at 11:02pm

Hi,

i'm working on a functionality where new members get an email when they have been added to the system.

code so far:

class Patient extends Member {

	private static $singular_name = "Patient";

	public function onBeforeWrite() {
		parent::onBeforeWrite();
		$result = $this->checkPassword($this->Password);
		$valid = $result->valid();
		if ($result->valid()) {
			return false;
		} else {
			$email = new Email();	 
	        $email->setTo($this->Email); 
	        $email->setSubject($valid);
	        $email->setFrom('no_reply@mysite.com'); 
	        $email->setTemplate('AccesGranted');
	        $email->populateTemplate(array(
			    'Email' => $this->Email,
			    'Password' => $this->Password
			)); 
	        $email->send();
    	}
	}
}

I think the problem is that the checkpassword function returns nothing. Can someone point me in the right direction?

thanks in advance