WPML
apply_filters( 'wpml_redirect_to_chosen_language', bool $enabled )
Type
filter
WPML Version
5.3.0

Description

Filters whether WPML keeps the language a visitor picks in a language switcher and shows the site in that language on their next visit.

Return false to turn this off for the current page. On that page, WPML does not save the language the visitor picks, and it does not send the visitor to the language they picked before. The browser language redirect and the language bar keep working as set.

Arguments

Parameters
  • $enabled(bool) Whether WPML keeps the language a visitor picks in a language switcher and shows the site in that language on the next visit. Defaults to the Show the site in the language they last picked in the language switcher setting in the Visitor language section of WPMLSettingsURLs and SEO.
Returns
(bool) Return false to turn it off for the current page.

Example usage

Do not save or use the picked language on the page with the slug landing:

add_filter( 'wpml_redirect_to_chosen_language', function ( $enabled ) {
	return is_page( 'landing' ) ? false : $enabled;
} );

wpml_decode_custom_field, wpml_footer_language_selector, wpml_add_language_form_field, wpml_ls_exclude_in_menu, wpml_is_rtl, wpml_alternate_hreflang, wpml_head_langs, wpml_must_translate_canonical_url, wpml_browser_redirect_language_params, wpml_active_languages

All 31 Site-Wide Language Information hooks