Jump to:

11001 Posts in 2733 Topics by 1823 members

All other Modules

SilverStripe Forums » All other Modules » Newsletter Module subscription page/process adding users and extending basic functionality a little, need help

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1261 Views
  • TF-35Lightning
    Community Member
    137 Posts

    Newsletter Module subscription page/process adding users and extending basic functionality a little, need help Link to this post

    Hi guys,
    I am trying to do a few things to the Newsletter Module sign up process and as this module isnt kept up to date before and I don't have that much knowledge of Silverstripe I have found this very difficult, and have gone off what is being discussed in these threads:

    All I want to do is.
    1. When user enter email address into subscription form their email is added to members table and appropriate group for mailing list (which is currently working)

    2. At the same time I want 2 new fields for this record, 1: to hold a randomly generated number 2: to have another field hold what the status is for this user (eg at the moment they in the table but they are unconfirmed because they havent clicked a link in the email I am about to send them )

    3. Send the user an email with a confirmation link that holds a link to the page where this checking will be done and obviously it needs to be something like mysite/mailinglist?email=theuser@theiraddress&randomnumber=3geg23r3wrf23f

    4. I then check to make sure the records email and randomnumber is the same before replacing my (unconfirmed, with confirmed)

    Here is what I have for step 1 which works, but as I mentioned I am a bit at a loss at how to do these other few steps and are hoping someone out there might be able to help me through it. Any help would be great

    Step 1: (user is added to membertable and appropriate group)


    class SignupPage extends Page {
    static $db = array(
    static $has_one = array(

    class SignupPage_Controller extends Page_Controller {

    // Make sure you set this to the right group. See http://doc.silverstripe.com/doku.php?do=show&id=recipes%3Aforms
    private $defaultGroupID = 3;

    //This function lets you put a form on your page, using $Form.
    function SignUpForm() {
    $fields = new FieldSet(
    // List your fields here
    new TextField("FirstName", "First name"),
    new TextField("Surname"),
    new EmailField("Email", "address"),       

    $actions = new FieldSet(
    new FormAction("SignupAction", "Sign up")

    $validator = new RequiredFields(
    "FirstName", "Surnname", "Email"       
    // List the required fields here: "Email", "FirstName"

    $form = new Form($this, "SignUpForm", $fields, $actions, $validator);
    return $form;

    // This function is called when the user submits the form.
    function SignupAction($data, $form) {

    // Create a new Member object and load the form data into it
    $member = new Member();

    // Write it to the database. This needs to happen before we add it to a group

    // Add the member to group. (Check if it exists first)
    if($group = DataObject::get_one('Group', "ID = $this->defaultGroupID")) {

    // Redirect to a page in this case the home page


    // Redirect to a failure page
    /* Director::redirect('failure/'); */




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.