21293 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » Member profiles module works, but Admin can't add members anymore
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: | 361 Views |
-
Member profiles module works, but Admin can't add members anymore

27 January 2012 at 10:45am Last edited: 27 January 2012 10:46am
Hello,
i have memberprofiles installed, and everything works.. on the front-end users can add themselfs.. emails get send etc..
but when logged in as admin, you can't add members in the CMS any more!This has got to do with the following code in MemberExtraStatistics.php
(this code extends Members and sends out the emails)<?php
class MemberExtraStatistics extends DataObjectDecorator {
function onBeforeWrite() {
if (!$this->owner->exists()) {
$email = new Email();
$data = $this->owner->getAllFields();$toAddress = Email::getAdminEmail();
$email->setTo($toAddress);$email->setSubject('Member activation required');
$email->setFrom($data['Email']);$email->setTemplate('EmailAccountActivation');
$email->populateTemplate($data);$email->send();
}
}The error in the CMS when adding a member:
[Notice] Undefined index: Email
POST /myproject/admin/security/EditForm/field/Members/AddForm?SecurityID=2a1cfb34e4d0bcef411795b803e31110a600d4dcLine 315 in /home/myproject/public_html/myproject/mysite/code/MemberExtraStatistics.php
Line 315:
$email->setFrom($data['Email']);
I think this script is trying to use the admin email (logged-in account/email) instead of the email entered in the form in the CMS.
Is this correct? and how should i rewrite this?
Thanks in advance!
-
Re: Member profiles module works, but Admin can't add members anymore

27 January 2012 at 11:20am
replace line 315 for
$email->setFrom($this->owner->Email);
and everything works!
credits for Zauberfisch
| 361 Views | ||
|
Page:
1
|
Go to Top |
