switch_to_locale( string $locale ): bool

In this article

Switches the translations according to the given locale.

Parameters

$localestringrequired
The locale.

Return

bool True on success, false on failure.

Source

 *
 * @param int $user_id User ID.
 * @return bool True on success, false on failure.
 */
function switch_to_user_locale( $user_id ) {
	/* @var WP_Locale_Switcher $wp_locale_switcher */
	global $wp_locale_switcher;

	if ( ! $wp_locale_switcher ) {
		return false;

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.