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

Member profiles module works, but Admin can't add members anymore


Reply


2 Posts   670 Views

Avatar
borriej

Community Member, 267 Posts

27 January 2012 at 10:45am

Edited: 27/01/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=2a1cfb34e4d0bcef411795b803e31110a600d4dc

Line 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!

Avatar
borriej

Community Member, 267 Posts

27 January 2012 at 11:20am

replace line 315 for

$email->setFrom($this->owner->Email);

and everything works!

credits for Zauberfisch