Filter: pll_preferred_language not working
-
excuse me in advance for the language errors (I speak French)
I need more information about this filter, I’m trying to set up a selection of the language by the user in his preferences on my site.
I save the language code in a user meta
I would like to use this filter so that the language is defined by this meta in priority but I can’t get this filter to work
here is my code:
add_filter('pll_preferred_language', 'set_preferred_language_to_user_meta', 10, 2);
function set_preferred_language_to_user_meta($slug, $languages) {?
if(current_user_is_logged()){
? ? $locale = get_user_meta(get_current_user_id(), 'locale', true);
? ? return empty($locale) ? ($slug === false ? 'en' : $slug) : $locale;
? }
return $slug === false ? 'en' : $slug;
}The meta contains “fr” or “en” but the result is that the language defaults to “fr” no matter what is in my meta
The page I need help with: [log in to see the link]
- The topic ‘Filter: pll_preferred_language not working’ is closed to new replies.