Redirect Member after login

First extend MemberLoginForm like this...

class MyMemberLoginForm extends MemberLoginForm {
 
    public function performLogin($data) {

        if($member = parent::performLogin($data)){
            Config::inst()->update('Security','default_login_dest',"admin");

            if($member->Email == 'special@email.com')
                Config::inst()->update('Security','default_login_dest',"specialemailurl");
        }
 
        return $member;
    }
}

Clearly the logic of where to redirect people to needs to be updated to your logic and destitation.

Then use this to replace the current class... add this to _config.php ...

Object::useCustomClass('MemberLoginForm','MyMemberLoginForm',true);
Rate this post (1 rating(s))

Post your comment

Comments

  • Greg 808 19/03/2018 4:18pm (6 years ago)

    In SS 4 you can set the redirects via YML like

    SilverStripe\Security\Security:
    default_login_dest: /[Controller]/[Action]

RSS feed for comments on this page | RSS feed for all comments