Hello !
On log in, I want the current page viewed to be "translated" (the user is redirected to the page in his own language/locale).
I already put this in the Page.php :
$member = Member::currentUser();
if($member && $member->Locale) {
//Translatable::set_locale($member->Locale);
Translatable::set_current_locale($member->Locale);
and when I log in, the menus get translated, but not the content.
So, I got this code on the amazing SSbits site :
http://www.ssbits.com/snippets/2010/customize-the-redirect-after-a-successful-member-login/
And I'm trying to modify it so when I log in, the site refreshes to the same page (ex: /contact), but with my locale defined as the current locale (/contact?locale=en_GB) so I would be redirected to /contact-en-gb.
The last line is what I invented wrote myself :
/// In LoginLocale.php :
class LoginLocale extends MemberLoginForm {
public function dologin($data) {
parent::dologin($data);
if( Director::redirected_to() and Member::currentUserID() ) {
$this->controller->response->removeHeader('Location');
$member = Member::currentUser();
$member_locale = $member->Locale;
Director::redirect(Director::baseURL() . Director::get_current_page()->UrlSegment . "?locale=" . $member_locale);
}
}
}
/// And in _config :
Object::useCustomClass('MemberLoginForm', 'LoginLocale');
I manage to set the locale, but the Current Page Url doesn't show anything -> I get to the homepage.
Can somebody help me with the last line ?