Jump to content

choose language of login and password forgot pages?


gerritvanaaken
 Share

Recommended Posts

The guest user language will be provided by default. You can change it.
If you want to control it via get parameter you need to hook in ProcessLogin::execute();
Pick up the language ID from the url get parameter and set the user language in a hookBefore.

  • Like 1
Link to comment
Share on other sites

  • 5 weeks later...

Hey @kixe Thanks for your answer. However, I couldn’t hook in correctly. I tried every hook from "ProcessLogin". The most suitable seemed "buildLoginForm" or "renderLoginForm", because I want the form itself to be translated. None of my hooking attempts seemed to be executed. This is from my init.php:

$wire->addHookBefore('ProcessLogin::buildLoginForm()', function($event) {
	wire('log')->save('langlog', 'language should be: '.wire('input')->lang);
	if (wire('input')->lang == 'fr') {
		wire('languages')->setLanguage(7085);
	}
});

I cannot explain why there is no log entry after visiting mysite.com/processwire/?forgot=1&lang=fr

Link to comment
Share on other sites

Here is my final init.php code for bilingual password forgot.

if (wire('session')->language) {
	wire('languages')->setLanguage(wire('session')->language);
}

$wire->addHookBefore('ProcessLogin::execute', function($event) {
	if (wire('input')->lang == 'fr') {
		wire('languages')->setLanguage(7085);
		wire('session')->language = 7085
	}
});

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...