In order to make the system really multilingual, according to everyone's preference, I've decided to add the language selection element directly to the initial registration form. Otherwise available in the user settings. This was done through an experimental plugin, not overriding the core code.
However, it does not function.
Views modified —
views/default/forms/register.php
– adding the select–option element:
[
'#type' => 'select',
'name' => 'language',
'value' => $language,
'required' => true,
'options_values' => $options,
'#label' => elgg_echo('user:language:label'),
],
Actions modified —
actions/register.php
getting the language as a selected option:
$language = $request->getParam('language');
As the $new_user object is created here,
I tried to add these lines to register the selection:
$new_user->language = $language; $new_user->save();
Outcome:
The new element of the registration form – selection of options of available languages – displays correctly. Picking data from this element seems not to be an obstacle because the same effect can be emulated by inserting a language code directly to the code, assigning $new_user->language = ...
But there is no change in the data of the newly registered user – the selected language is not saved, the default one remains. → no result
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
- Jerome Bakker@jeabakker

Jerome Bakker - 0 likes
- Avinty Lanaikey@tandit

Avinty Lanaikey - 0 likes
- Avinty Lanaikey@tandit

Avinty Lanaikey - 0 likes
- Nikolai Shcherbin@rivervanrain

Nikolai Shcherbin - 0 likes
You must log in to post replies.By default, register() use the system current language:
$user->language = $this->translator->getCurrentLanguage();
You may want to use 'create', user' event hook or 'register', 'user' plugin hook to override the language parameter.
Look at this fork also.
the problem is probably related to not having access to save the data to the user.
if you wrap you code in an elgg_call() like this:
In order for you not having to overrule the registration action you could listen to the 'register', 'user' hook like Nikolai suggested.
PS: this also pointed out a probable bug in the registration action ;)
Well. In the end, it appeared the fault was a missing registration of the action in elgg-plugin.php, therefore not inaccessible in the system. It was found out that other fields like the name were not modifiable from inside the code either. The solution was to add the action with ['access' => 'public'] to elgg-plugin.php. The elgg_call function is even not necessary. Now it's functioning.
The original Language Selector plugin
https://elgg.org/plugins/384977
is incompatible with new versions. It still contains the outdated start.php instead of elgg-plugin.php.
And the GitHub/RiverVanRain variant
https://github.com/RiverVanRain/language_selector/tree/3.3
couldn't be activated. It throws a fatal error:
This plugin isn't compitable with Elgg 4.
You can use it as an example for development.
Any contributions are welcome ;)