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

Is User Registration Possible?


6 Posts   3815 Views


8 May 2009 at 12:38am Community Member, 1 Post

I'm struggling to find any documentation in regards to getting users to sign up.

There seems to be a bunch of security/authentication stuff but nothing which actually tells me how to set up users in a SilverStripe project?


8 May 2009 at 1:00am Community Member, 108 Posts

Oh yes, very easily.

You are going to create a new page (I called mine RegistrationForm.php) and save it in you mysite/code/RegistrationForm.php

See my RegistrationForm.php below.

Then you need to create a and save that in your project/templates/

The will look similar (if you want) to the The main variable you need in this page is $Form which is passed from the RegistrationForm.php

If you need to include the email notification like I did you will want to create a that is used to format the email that gets sent.

Notice in the RegistrationForm.php there is a setTemplate that directs the page to use as the template as well as the

I hope this helps. You can see it in action if you would like at


class RegistrationForm extends Page {

class RegistrationForm_Controller extends Page_Controller {

   // Make sure you set this to the right group.
   // See
   private $defaultGroupID = 2;

   * This function lets you put a form on your page, using $Form.
   function Form() {
      return new Form($this, "Form", new FieldSet(

         // List your fields here
         new EmailField("Email", "Email address"),
         new PasswordField("Password", "Create a Password"),
         new TextField("FirstName", "First name"),
         new TextField("LastName", "Last name"),
         new TextField("Phone", "Phone"),
         new TextField("Company", "Company/Hospital"),
         new TextField("Address1", "Address 1"),
         new TextField("Address2", "Address 2"),
         new TextField("City", "City"),
         new TextField("State", "State"),
         new TextField("Zip", "Zip"),
         new TextField("Country", "Country"),
         new ReadonlyField("IPAddress","IPAddress",$_SERVER['REMOTE_ADDR'])

      ), new FieldSet(

         // List the action buttons here
         new FormAction("SignupAction", "Submit")

      ), new RequiredFields(

         // List the required fields here: "Email", "FirstName"
         "Email", "Password", "FirstName", "LastName", "Phone", "Company", "Address1", "City", "State", "Zip", "Country"


   * 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 = 2")) {

         // Redirect to a page thanking people for registering
         //Set data
            $From = $data['Email'];
            $To = "email address of who gets the email, 2nd email addres";
            $Subject = "Registration Request";
            $email = new Email($From, $To, $Subject);
            //set template
            //populate template
            //send mail
         //$e = new Email();
         //$e->To = "";
         //$e->Subject = "Registration Request";
//         $e->Body = populateTemplate($data);

         //$e->Body = $member;


         // Redirect to a failure page





8 May 2009 at 2:39am (Last edited: 8 May 2009 2:40am), Community Member, 145 Posts

Terry, when you post code, its best to surround it with [ code ][ /code ] tags, it displays better and makes it easier to read


8 May 2009 at 2:59am Community Member, 108 Posts

Thanks for this. I will do this next time.



14 June 2009 at 10:12pm Community Member, 6 Posts

Hi Terry, thanks for the example. Can you explain more about how and where the additional member data fields are processed and saved (which table). By following the example I can save names, email and password (all fields are displayed in form) into existing member table and assign to a group but am I missing something here ($db?) to save additional fields??? Thanks.
nb: I have added a similar question to another post too.


18 June 2009 at 1:54pm Community Member, 6 Posts

More clues here;

and here (this link is at bottom of above post);

this tutorial may be useful for you :

Also, in one of the tutorials in suggests, if you want to just grab peoples details and not give them any 'logged in' capabilities, then don't register them (with a password) in the core members table.
The Forum module is perfect for seeing how to extend the current member table, if you do need to do it tho.