Jump to content
gerritvanaaken

choose language of login and password forgot pages?

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
2 hours ago, gerritvanaaken said:

This is from my init.php:

Does it all also not work when executed in the ready.php?

Share this post


Link to post
Share on other sites

I’m such a noob! I used the hook with function parentheses. ProcessLogin::execute() is wrong. ProcessLogin::execute works totally fine. Thanks, case closed!

Share this post


Link to post
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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By GeraldSchmidt
      Hello everyone
      i gotta simple problem everytime after refreshing my backend, the fields that i have closed before are still opened (For example the repeater).
      is there a (maybe localstorage) functionality which remembers the action in relation to the open/close activity?

    • By dotnetic
      I am looking for a developer who can extend the comments fieldtype for me.
      I need two additional fields:
      add a field "title" add a star rating field (in backend and frontend) the rating field in the backend can be an input field and does not have to display as stars, but would be nice. The frontend needs to display the rating as stars. There are two Star Rating modules already available, one is a rating for pages
      https://processwire.com/talk/topic/7871-page-ratings/
      the other 
      https://processwire.com/talk/topic/10107-fieldtypestarrating/ is a fieldtype.
      I need a solution that has the ability to be rendered as average ratings (so half stars are possible, you can find the code in the first module I mentioned, the second one just handles integers).
      There are two types of output. One is for amazon.de products and will show average ratings (see attached screenshot)
      and the other one is for a comment and only shows full stars.
      Pls provide me an offer/estimate.
      After we agreed, I provide you with FTP and Backend access and you tell me which files changed.
      Work needs to be done until 21. August 2015.

×
×
  • Create New...