Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » How to save Member Password manually?

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

Page: 1
Go to End
Author Topic: 513 Views
  • novaweb
    Avatar
    Community Member
    111 Posts

    How to save Member Password manually? Link to this post

    Greets,

    I am trying to make a registration form for Members, but cannot use $form->saveInto($member) due to custom functionality.

    This does not work: http://pastie.org/3718370

    It gives me a server error and defaults to the blackcandy template.

    Can anyone advise?

    Cheers,
    Nova

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: How to save Member Password manually? Link to this post

    Hi,

    I've done this in the past that should save you some lines of code too (assuming your form is setup correctly)...

    $doMember = new Member($data);
    $doMember->write();

          

    alternativly if you check the docs you could make the member and then set the password with a fucntion...

    http://api.silverstripe.org/2.4/sapphire/security/Member.html#methodchangePassword

  • novaweb
    Avatar
    Community Member
    111 Posts

    Re: How to save Member Password manually? Link to this post

    Thanks Swaiba, I couldn't do you first method as I was not able to make the Form Field Names match the Names of the Fields in the Database due to third party applications relying on certain Field Names. However, your changePassword suggestion helped me do the following:

       function doRegister($data, $form) {

             // Write the new member to the SilverStripe Database
             $member = new Member();
             $member->FirstName = $data['GivenName'];
             $member->Surname = $data['FamilyName'];
             $member->Email = $data['EMail']['Home'];
             $password = $data['Password']['_Password'];
             $member->changePassword($password);
             $member->write();
             return Director::redirect('please-verify-your-account/');   
       }

    Cheers,
    Nova

    513 Views
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.