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.

Customising the CMS /

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

Has anyone created a user profile page successfully?

Go to End

4 Posts   3264 Views


Community Member, 121 Posts

7 August 2009 at 7:50am

Has anyone created a user profile page successfully? With information editing capability in particular. Updating password would be the most important one.


Community Member, 712 Posts

7 August 2009 at 9:28am

Have a look at the forum module - this has this capability.


Community Member, 288 Posts

7 August 2009 at 11:17am

SilverStripe has a standard change password form that you can use. There's a form called ChangePasswordForm that you can just plug right in without having to do any modifications.

I use it like this

	public function ChangePassword() {
		return new ChangePasswordForm($this, 'ChangePassword');

That goes in the controller of your choice (I don't know if you can put it in the model as well) and then you just type $ChangePassword in your template to output the form.

All the behind the scenes mojo is taken care of so you don't have to worry about it.

When it comes to the user profile page I rolled my own.

It looks like this

	function ContactForm() {
		$member = $this->CurrentMember();
            // Create fields         
        $fields = new FieldSet(
            new TextField('FirstName', 'First Name*', $member->FirstName),
            new TextField('LastName', 'Last Name*', $member->Surname),
            new TextField('Email', 'Email (User Name)*', $member->Email)
        // Create action
        $actions = new FieldSet(
            new FormAction('ChangePersonalDetails', 'Change')
        // Create Validators
        $validator = new RequiredFields('FirstName', 'LastName', 'Email');
        return new Form($this, 'ContactForm', $fields, $actions, $validator);

And then this to save

	function ChangePersonalDetails($data) {
		$member = $this->CurrentMember();
		$member->FirstName = $data['FirstName'];	
		$member->Surname = $data['LastName'];
		$member->Email = $data['Email'];

        //return to submitted message
        Director::redirect(Director::baseURL(). $this->URLSegment);

I bet it can be done alot more robustly but this should get you started.



Community Member, 10 Posts

25 February 2012 at 8:39pm

Edited: 25/02/2012 8:39pm

Andrew Short has done so, and it's a very full-featured module.

See here:

- L