switch_to_user_locale( int $user_id ): bool

In this article

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

Parameters

$user_idintrequired
User ID.

Return

bool True on success, false on failure.

Source

 *
 * @return string|false Locale on success, false on error.
 */
function restore_previous_locale() {
	/* @var WP_Locale_Switcher $wp_locale_switcher */
	global $wp_locale_switcher;

	if ( ! $wp_locale_switcher ) {
		return false;
	}

Changelog

VersionDescription
6.2.0Introduced.

User Contributed Notes

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