• Resolved krystianj

    (@krystianj)


    Hi,
    It is possible to set default post language based on profile language settings?

    For example:
    user1 has set languge to English (in Profile) and when he is posting the default post language is english.
    user2 has set language to Deutsch (in Profile) and when he is posting the default post language is Deutsch.

    Can I set this “Polylang – language” (right sidebar when add post) select form to language based on user locale?

    • This topic was modified 9 years, 4 months ago by krystianj.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter krystianj

    (@krystianj)

    Hi,
    I know that default language is set up in ‘admin-filter-posts.php’ in line 219 where:
    'selected' => $lang ? $lang->slug : '',

    Can I override this in my functions.php ?

    I want have instead $lang->slug – get_user_locale()

    Any idea?

    Thread Starter krystianj

    (@krystianj)

    I don’t know is this best solution but I use javascript for this

    function print_my_inline_script_custom() {
      $lang = get_user_locale();
      $lang_name = explode('_', $lang);
        echo '<script type="text/javascript">
                document.addEventListener("DOMContentLoaded", function(event) {
                document.getElementById("post_lang_choice").value="'. reset($lang_name) .'";
                });
              </script>';
    }
    
    add_action( 'admin_init', 'print_my_inline_script_custom' );
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Default language based on user language setting’ is closed to new replies.