Fix missing redirect to the URL configured in com_user in multilanguage environment#9710
Fix missing redirect to the URL configured in com_user in multilanguage environment#9710mannybiker wants to merge 2 commits intojoomla:stagingfrom
Conversation
…in a multilanguage site that use menu associations and the Automatic Language Change features of languagefilter plugin
|
A few first remarks.
A bit confusing: A login redirection is done in the login menu item or the login module (i.e. redirect URL), not in the User Profile. I guess you mean the user preferred language redirection? In this case your patch does not solve this. My test: Quite restrictive in the sense that using a login module instead of a menu item has no effect at all. Also, the formatting of the redirect link in the menu item is quite special as it has to be something like (redirect to a Spanish item on a 7 languages site where the user default preferred language is English and general default language is French.): Therefore a user which preferred site language is English logging in the Italian part of the site by this login menu item is redirected to an item in the Spanish part of the site. It is logical as all depends on the url redirect entered in the Login menu item, not any more on the user preferred language. Last, we get a Notice:
i.e. for |
|
Yes, sorry for the confusion, as per the screenshots and the first point of the testing instruction is the Login Redirect URL in the Option of the Login Form menu item. The problem happens when the user do the login in a language different from the one he has set in his profile preferences. For example he configured the italian language in his profile but when he visits as a guest the website the default english language is proposed. He does not change the language before logging in, as the 90% of the users do, since he knows that the system will recall his preferred language after the login and he can easily and quickly login in any case without switching to his mother language. During the login the system will automatically changes the front end language and try to find if there is an associated menu to the user preferred language. If the association exists the URL redirection set in the users.login.form.return variable is overwritten and the data coming from the hidden input named "return", that is set in the login form to reflect the "Login Redirect" URL configured in the menu, is lost. I think that if there is an option to decide a redirect URL, this choice has to be respected in any circumstances. I understand that you see useless and illogical to redirect someone to a spanish page when he is english, but this happen only if you hard code the language code in the url, that as you tell me should be mandatory. But I am using a different approach to redirect the users to the right page in their preferred language. For the PHP Notice I need to check why you get this, there must be a case that generate this error that I do not have. |
I doubt it.
This would redirect to the item, whatever its language, with the URL Language Code of the page where the login menu item is used, if the language is not set to "All". if the item is set to a different language, 404. In any case, the user preferred language is not used at all. |
|
Ok, I may have solution, using part of your code (no more Notice): Whatever the item entered as redirect url (including items set to a different language than the page on which the user logs), it would let redirect to the correct item, including when using the login module, with no possible 404 (as long as the item exists). _Basically, if there is a redirect url (in the login menu item as well as in the login module) the solution will anyway override the user preferred site language setting._ It implies the correct formatting of the url entered for the redirect url in the login menu item: , should always be an internal url and should include Example: index.php?option=com_content&view=article&id=151&catid=21&lang=es-ES&Itemid=131 For the module and the logout menu item, the solution takes automatically care of the language. Will make a PR. |
|
Please test: #9724 |
|
Many thanks Jean-Marie for your kindly interest. I am sorry but being in a trip I am a bit slow to react. |
|
Never add pass/names in a post. Please immediately delete these from that site. |
|
I tested your site. It is not really set as a multilingual site as the content categories and articles are all set to ALL languages. This explains the results you get. |
…sing TOS user registration form field validation
|
Hi Jean-Marie. Your code is good but I still have a problem with it. I configured the respective login menu items for both languages to point to the home page in the right language and everything was fine. But now I had a new problem. If the user saved a language preference (and I wanted to let the site change language automatically based on his preference) and he did not login within the corresponding language, obviously the redirection will 404. You solved this problem now, but we are in the illogical situation you described some posts ago, of having a user with a preferred language be transferred to a total different one. With my previous dirty patch I am for sure not able to avoid 404 as you can with yours, but in some way I was able to redirect a user always to the same address that was "index.php?option=com_content&view=featured", assigned every time to a menu item for every languages and let the CMS redirect correctly after the login to the user preferred language. This is not a global solution, but resolve my case scenario. So to resume, before any patches in a MultiLanguage environment if I use a redirect I will raise 404, if I don't use it I will have error messages about the access denied trying to access the login item no more accessible and with your patch I will redirect the user to the wrong language. In any case thank you for your precious time and help. I know how much time people who develop for the community spent and subtract to their life, because I am the first having hard time to find some spare time to trying to help. |
|
as i said, on multilingual site, redirecting to a menu item set to all languages that would have the same url path for all content languages, is rather weird. |
|
this can be closed as we have a patch. see #9724 |
|
Closing in favor of #9724 |
Pull Request for Issue # .
Summary of Changes
Added to onUserLogin method of Class PlgSystemLanguageFilter some further test to take into account a previously set users.login.form.return parameter that the plugin incorrectly overwrite in case of MultiLanguage menu association.
Testing Instructions
A PDF file with some screenshots is also attached to better describe the testing environment. The bug is not related to the "Login for Guest / Logout for registered" method shown in the PDF, but this use case underline the importance of having the redirect after login working, since without it Joomla will raise an access denied error.
languagefilter.pdf