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

Send email notification after editing a member's details?


6 Posts   1218 Views


16 August 2011 at 10:52pm Community Member, 49 Posts

For members in my site, I have set a status field. The idea is that admins can login to the CMS and set a newly registered member from 'Disabled' to 'Enabled'.

What I am wanting to do is have an email be sent out to a member when their status is updated to enabled...

Admins are using the security tab in the CMS to achieve this.

How would I go about having an email fire off when an admin updates their status to 'Enabled'?



17 August 2011 at 8:02am Community Member, 49 Posts

Just letting anyone whose interested know I came across this post:

One thing I am unsure about though....

If I add an onAfterWrite function into my decorator, how do I call the Member DataObject's native onAfterWrite function first? Those examples use parent::onAfterWrite();.....but I thought it would have been $this->owner->onAfterWrite(); ?


17 August 2011 at 8:48am Community Member, 72 Posts

I was able to set up something similar. When a registered user is marked 'Enabled' by an admin it emails the registered member.

I'm not sure how you are trying to do this, but inside my MediaMember.php I have a onAfterWrite() function that handles the emailing. the parent::onAfterWrite() handles everything else.

class MediaMember extends DataObjectDecorator {
function onAfterWrite() {
      if($this->checkStatus == 'Disabled' && $this->owner->Status == 'Enabled') {
         if($this->selUser->inGroup('media-access')) {
            $email = new Email();
            $email->setSubject('Account Enabled');

you shouldn't have to call the member's dataObject as you are in the DataObjectDecorator which references the Member you are currently editing. $this->owner is the member's dataobject.


20 August 2011 at 8:18pm Forum Moderator, 5511 Posts

You don't need to call parent::onBeforeWrite() (or after) in any decorators as the actual function (onBeforeWrite) will already be the callee. You only need to explicitly call it when you're subclassing a dataobject (not decorating)


20 August 2011 at 8:22pm Community Member, 72 Posts

makes sense, this is good to know.


20 August 2011 at 8:37pm Community Member, 49 Posts

Thanks Moloko_man and also Willr, got this working :)