switch_locale action-hookWP 4.7.0

Fires when the locale is switched.

Usage

add_action( 'switch_locale', 'wp_kama_switch_locale_action', 10, 2 );

/**
 * Function for `switch_locale` action-hook.
 * 
 * @param string    $locale  The new locale.
 * @param false|int $user_id User ID for context if available.
 *
 * @return void
 */
function wp_kama_switch_locale_action( $locale, $user_id ){

	// action...
}
$locale(string)
The new locale.
$user_id(false|int)
User ID for context if available.

Changelog

Since 4.7.0 Introduced.
Since 6.2.0 The $user_id parameter was added.

Where the hook is called

WP_Locale_Switcher::switch_to_locale()
switch_locale
wp-includes/class-wp-locale-switcher.php 98
do_action( 'switch_locale', $locale, $user_id );

Where the hook is used in WordPress

Usage not found.