<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Page comments</title>
		<link>http://www.ssbits.com/home/</link>
		<atom:link href="http://www.ssbits.com/home/" rel="self" type="application/rss+xml" />
		<description></description>

		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_2190</link>
			<description>Very good tutorial.
In my case I need redirect the user after login, according to their permissions. If is administrator goes to CMS admin, if is a student goes to the student profile.
I made small modifications in the code to silverstripe 3.0.3:

public function dologin($data) {
        parent::dologin($data);
        if( $this-&gt;controller-&gt;redirectedTo() and Member::currentUserID() ) {
            $member = Member::currentUser();
           
            if(Permission::checkMember($member, &quot;STUDENT_ACCESS&quot;))
            {
                $this-&gt;controller-&gt;response-&gt;removeHeader('Location');
                $this-&gt;controller-&gt;redirect(SiteTree::get_by_link('student')-&gt;Link());
            }
            else if(Permission::checkMember($member, &quot;CMS_ACCESS_LeftAndMain&quot;))
            {
                $this-&gt;controller-&gt;response-&gt;removeHeader('Location');
                $this-&gt;controller-&gt;redirect(singleton('CMSMain')-&gt;Link());
            }
        }
    }</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_2190</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_1981</link>
			<description>A little bit late on this one , but an easy (albeit very hacky) way of doing it is if you add this to a js file that is called on every page:

 $('input[name=BackURL]').each(function(){
        $(this).val('WHATEVERURLYOUWANT');
    });
(obviously requires jQuery, but i'm sure it can be re-written for vanilla javascript)

this means you don't have to have a seperate template file for your login and is essentially *global*</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_1981</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_262</link>
			<description>Ahh, very interesting!  I had never noticed that feature before even though SVN says that Sam added it 2+ years ago: http://open.silverstripe.org/changeset/62653

That is certainly an easier way to direct to an URL segment after login.  I suppose you'd only need my snippet above if you had custom logic you'd like to introduce.  Thanks Rick, nice catch!

Note that setting Security::set_default_login_dest() will always be overridden by the presence of a BackURL=xxxxx URL parameter.</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_262</guid>
		</item>
		
		<item>
			<title></title>
			<link>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_261</link>
			<description>Enjoyed your Snippet!

Perhaps a simpler way (to set a site wide redirect after login) is to set the default login destination (e.g. in _config.php):
	Security::set_default_login_dest('urlsegment');

Though I always try to return to the calling page (after login) by setting a redirect in the login link (e.g. in the page template):
	&lt;a href=&quot;http://www.ssbits.com/Security/login?BackURL=//&quot; title=&quot;Login&quot;&gt;Login&lt;/a&gt;
</description>
			<pubDate></pubDate>
			<dc:creator>RSSName</dc:creator>
			<guid>http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/#PageComment_261</guid>
		</item>
		

	</channel>
</rss>