switch_locale
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
switch_locale
wp-includes/class-wp-locale-switcher.php 98
do_action( 'switch_locale', $locale, $user_id );