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

Email on alteration to dataobject in CMS?


Reply


4 Posts   413 Views

Avatar
JonC

Community Member, 8 Posts

2 November 2011 at 4:13pm

Hi, guys.

Question: is it possible to have SS send an email to an email address stored in a particular DataObject when that DataObject is altered and then saved in the CMS?

Avatar
Devlin

Community Member, 225 Posts

2 November 2011 at 9:17pm

class MyDO extends DataObject {
   function onBeforeWrite() {
      parent::onBeforeWrite();
      
      $email = new Email();
      $email->sendPlain();
   }
}

http://doc.silverstripe.org/sapphire/en/topics/datamodel

Avatar
JonC

Community Member, 8 Posts

3 November 2011 at 7:51pm

Thanks!

Further refinement: is it possible to have it send that email only when a certain specific database field is changed?

Avatar
swaiba

Forum Moderator, 1808 Posts

3 November 2011 at 11:39pm

yes, check out this method...
http://api.silverstripe.org/2.3/sapphire/model/DataObject.html#methodgetChangedFields