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.

We've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Redirect to a page after login

Go to End

6 Posts   9844 Views


Community Member, 13 Posts

2 April 2009 at 9:43pm

How can I redirect to a specific page after login? I use $LoginForm on the frontpage, and want the users to end up at /account after successful login.

Carbon Crayon

Community Member, 598 Posts

8 April 2009 at 2:09am

Edited: 08/04/2009 2:09am

Hi Sec

I have just poste a tutorial on SSbits to do just this :)

hope it helps



Community Member, 215 Posts

8 April 2009 at 1:09pm

Hi Aram, looks great :) added it to my Google Reader.

One question, how could we extend this to redirect to a specific page in the admin ie. based on the security group?


Carbon Crayon

Community Member, 598 Posts

14 April 2009 at 1:17am

Edited: 14/04/2009 1:17am

Hi Howard

Sorry for the late reply, I forget to subscribe to this thread and just came accross it again!

The way to do this is to have the link be /admin/show/$ID of the page you want to redirect to. So I image you extract the Id from the TreeDropdownField and insert it into the redirector so change these lines:

$Link = DataObject::get_by_id("SiteTree", "{$Group->LinkPageID}")->URLSegment;

to this:

$ID = DataObject::get_by_id("SiteTree", "{$Group->LinkPageID}")->ID;

Abd this line:

Director::redirect(Director::baseURL() . $Link);

to this:

Director::redirect(Director::baseURL() . "admin/show/" . $ID);

That should work :)



Community Member, 1 Post

23 April 2009 at 9:27am

Edited: 23/04/2009 9:32am

I've used the code as ssbits but for some reason I can't get users to redirect. After login it says "I'm sorry, but you can't access that part of the CMS. If you want to log in as someone else, do so below"

I have setup the page using $LoginForm

Also, after I login on this page and I get that message, if I try to goto the page where this user is ABLE to access, it makes me login again @ /Security/login

then if I go directly to /Security/login, it will log in and say welcome back, user. you are logged in as user. and there will be no redirect.


Community Member, 2 Posts

3 August 2017 at 4:39pm

Thanks Carbon Crayon, where do you replace this code? Your link to ssbits is broken.