gerritvanaaken Posted November 6, 2019 Share Posted November 6, 2019 If my backend has two languages, is there any way to force (via URL parameter?) which language will be displayed on the login page and the password forgot page? Link to comment Share on other sites More sharing options...
kixe Posted November 6, 2019 Share Posted November 6, 2019 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. 1 Link to comment Share on other sites More sharing options...
gerritvanaaken Posted December 6, 2019 Author Share Posted December 6, 2019 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 More sharing options...
horst Posted December 6, 2019 Share Posted December 6, 2019 2 hours ago, gerritvanaaken said: This is from my init.php: Does it all also not work when executed in the ready.php? Link to comment Share on other sites More sharing options...
gerritvanaaken Posted December 6, 2019 Author Share Posted December 6, 2019 I’m such a noob! I used the hook with function parentheses. ProcessLogin::execute() is wrong. ProcessLogin::execute works totally fine. Thanks, case closed! Link to comment Share on other sites More sharing options...
gerritvanaaken Posted December 9, 2019 Author Share Posted December 9, 2019 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 } }); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now