Preferred Language option is not available into the edit profile page

Preferred Language option is not available into the edit profile page

by Tania Karga -
Number of replies: 4

Dear all,
we are using moodle version 3.5 and we have noticed that the preferred language option is not available inside the edit profile page. This option would be very useful to be visible for the admin user when s/he editing the profile pages of other users.

We are aware that we can access the preferred language option by the Preferences page but this is not practical in case you want to change not only the preferred language but also other user profile settings like the city, country, timezone etc at the same time.

Is there a way to make the preferred language option visible into the edit profile page?

Thank you in advance,

Average of ratings: -
In reply to Tania Karga

Re: Preferred Language option is not available into the edit profile page

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

It was there in the past and it was intentionally moved to Preferences as a part of the MDL-45774.

It was reported that the change had caused a regression that the admin can no longer set the user's preferred language upon creation. If that is your issue as well, please refer to MDL-60409.

Average of ratings: Useful (1)
In reply to David Mudrák

Απάντηση: Re: Preferred Language option is not available into the edit profile page

by Tania Karga -

Thank you David for your immediate reply.

The preferred language option is visible for us into the “add a new user” page, since we use the moodle version 3.5. Our problem was the lack of the preferred language option into the “edit profile” page. We have just solved this problem.

If anyone is interested to make the preferred language option (into the “edit profile” page) visible for the admin user, then s/he can do it by changing the user\editlib.php file.

Specifically, for moodle version 3.5 in line 329

Remove:  if ($user->id < 0) {

Add:      $context = CONTEXT_SYSTEM::instance();

                if ($USER->id < 0 || has_capability('moodle/site:configview', $context) ) {


Average of ratings: Useful (1)
In reply to Tania Karga

Re: Απάντηση: Re: Preferred Language option is not available into the edit profile page

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Just to clarify, to allow admins and other relevant users (such as mentors, parents etc) to set the preferred for other users while editing their profile, I would suggest this change:

diff --git a/user/editlib.php b/user/editlib.php
index d5bbd1ed4f..bf10f66d5b 100644
--- a/user/editlib.php
+++ b/user/editlib.php
@@ -327,7 +327,7 @@ function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions
         $mform->addElement('select', 'timezone', get_string('timezone'), $choices);
     }

-    if ($user->id < 0) {
+    if ($user->id < 0 || has_capability('moodle/user:editprofile', context_user::instance($user->id))) {
         $mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
         $lang = empty($user->lang) ? $CFG->lang : $user->lang;
         $mform->setDefault('lang', $lang);

Please feel encouraged to report this into the tracker, together with real world use cases of when admins need this. I can imagine this would become the standard behaviour (again). Alternatively, maybe we could just remove the condition and let it appear on the profile page for users themselves, too.

Average of ratings: Useful (2)
In reply to David Mudrák

Απάντηση: Re: Απάντηση: Re: Preferred Language option is not available into the edit profile page

by Tania Karga -

Thank you David! I really appreciate your suggestion!