Jump to:

23377 Posts in 18296 Topics by 2867 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, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 620 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    Member profiles module works, but Admin can't add members anymore Link to this post

    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!

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Member profiles module works, but Admin can't add members anymore Link to this post

    replace line 315 for

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

    and everything works!

    credits for Zauberfisch

    620 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.