开发者

Redirect into SilverStripe's pages

I'm trying to set up a redirect on my SilverStripe site.

I have created my own module, and now I want the user to be redirected to that after log in.

I've tried with Director::redirect($Url_base . 'myModule'), but it do开发者_开发技巧esn't work.

Does anyone have any suggestions?


Try this: http://www.ssbits.com/customize-the-redirect-after-a-successful-member-login/


I did something like this:

class MyLoginForm extends MemberLoginForm {
    public function dologin($data) {
        parent::dologin($data);
        if (Director::redirected_to() && $Member = Member::currentUser()) {
            $this->controller->response->removeHeader('Location');
            if ($Member->Email == 'admin') {
                $destination = '/admin';
            } else {
                $destination = '/user/' . $Member->Username;
            }
            Director::redirect($destination);
        }
    }
}

If it is the admin user I redirect them to /admin. If it is another user I redirect them to /user/username.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜