21304 Posts in 5736 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Send email notification after editing a member's details?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 915 Views |
-
Send email notification after editing a member's details?

16 August 2011 at 10:52pm
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'?
Thanks.
-
Re: Send email notification after editing a member's details?

17 August 2011 at 8:02am
Just letting anyone whose interested know I came across this post: http://silverstripe.org/general-questions/show/12197
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(); ?
-
Re: Send email notification after editing a member's details?

17 August 2011 at 8:48am
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->setTo($this->owner->Email);
$email->setSubject('Account Enabled');
$email->setFrom('no_reply@mysite.com');
$email->setTemplate('AccessGranted');
$email->populateTemplate($this->owner);
$email->send();
}
}
parent::onAfterWrite();
}
}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.
-
Re: Send email notification after editing a member's details?

20 August 2011 at 8:18pm
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)
-
Re: Send email notification after editing a member's details?

20 August 2011 at 8:22pm
makes sense, this is good to know.
-
Re: Send email notification after editing a member's details?

20 August 2011 at 8:37pm
Thanks Moloko_man and also Willr, got this working
| 915 Views | ||
|
Page:
1
|
Go to Top |



