do_action( 'switch_locale', string $locale, false|int $user_id )
- Since
- 4.7.0, 6.2.0
Fires when the locale is switched.
Compatibility
- WordPress
- since 6.2.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$localestring- The new locale.
$user_idfalse|int- User ID for context if available.
Where this hook fires · 1
wp-includes/class-wp-locale-switcher.php:98WP_Locale_Switcher::switch_to_locale()
Source code
* @since 4.7.0 * @since 6.2.0 The `$user_id` parameter was added. * * @param string $locale The new locale. * @param false|int $user_id User ID for context if available. */ do_action( 'switch_locale', $locale, $user_id ); return true; } /** * Switches the translations according to the given user's locale.Changelog
Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
6.2.0
The
$user_id parameter was added.from the docblock4.7.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.