Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » newsletter signup form

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1048 Views
  • grilldan
    Community Member
    135 Posts

    newsletter signup form Link to this post

    *update4* SOLVED
    in SugnupForm.php, changed

       $groups = $member->Groups();
          $groups->setByCheckboxes(array("newslettersubscribe"), $data);


    if($group = DataObject::get_one('Group', "Code = 'newslettersubscribe'")) {

    I need some way to get Member id and add it to the Gourp_Member table when people register for the newsletter.

    *update 2*
    When I add a member manually from the newsletter tab in the admin panel, the row is added to the member table, in the same format...

    I figured out that it is writing to the "Member" table in the database. Is there a way for the news letter to automatically add members from the Member list?


    I followed the guide here:

    (I see the note saying its outdated.)

    What could be done to make this work? The only problem I have is that it isn't adding anything to the database.

    here is what I have:


    class SignupForm extends Form {   
       function signup($data,$form) {
          // Create a new member using the data from the form
          // TODO: needs validation - all fields filled out, email doesn't exist already etc
          $member = new Member($data);
          // Add the new member to the 'newslettersubscribe' group
          $groups = $member->Groups();
          $groups->setByCheckboxes(array("newslettersubscribe"), $data);
          // Write the Member table row


    class SignupPage extends Page {

    class SignupPage_Controller extends Page_Controller {
       function AfterContent() {
          // This is a dirty hack, suggestions?
          // It returns early if we're on the thanks page - we don't want the form on that page
          if($this->urlParams[Action] == 'thanks') return;
          return new SignupForm($this, "AfterContent",
             new FieldSet(
                new TextField("FirstName", "First Name:"),
                new TextField("Surname", "Surname:"),
                new TextField("Email", "Email:")
             new FieldSet(
                new FormAction("signup", "Subscribe")

             new RequiredFields(

    I have a newsletter named newslettersubscribe. I made it from the newsletter tab of the admin panel.

    I know there is a "subscribe form" page type, but I don't want the users to need to use a checkbox for selecting the news group.

    Is there a way to set a "default" news group maybe?

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.