WP_Locale_Switcher::switch_to_user_locale()publicWP 6.2.0

Switches the translations according to the given user's locale.

Method of the class: WP_Locale_Switcher{}

No Hooks.

Return

true|false. True on success, false on failure.

Usage

$WP_Locale_Switcher = new WP_Locale_Switcher();
$WP_Locale_Switcher->switch_to_user_locale( $user_id );
$user_id(int) (required)
User ID.

Changelog

Since 6.2.0 Introduced.

WP_Locale_Switcher::switch_to_user_locale() code WP 6.5.3

public function switch_to_user_locale( $user_id ) {
	$locale = get_user_locale( $user_id );
	return $this->switch_to_locale( $locale, $user_id );
}