5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1788 Views |
-
Has anyone created a user profile page successfully?

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.
-
Re: Has anyone created a user profile page successfully?

7 August 2009 at 9:28am
Have a look at the forum module - this has this capability.
-
Re: Has anyone created a user profile page successfully?

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();
//var_dump($member);
// 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'];
$member->write();//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.Kindly,
Marcus -
Re: Has anyone created a user profile page successfully?

25 February 2012 at 8:39pm Last edited: 25 February 2012 8:39pm
Andrew Short has done so, and it's a very full-featured module.
See here: http://github.com/ajshort/silverstripe-memberprofiles
- L
| 1788 Views | ||
|
Page:
1
|
Go to Top |


