do_action( 'switch_blog', int $new_blog_id, int $prev_blog_id, string $context )
- Since
- MU (3.0.0), 5.4.0
Fires when the blog is switched.
Compatibility
- WordPress
- since 5.4.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
$new_blog_idint- New blog ID.
$prev_blog_idint- Previous blog ID.
$contextstring- Additional context. Accepts 'switch' when called from switch_to_blog() or 'restore' when called from restore_current_blog().
Where this hook fires · 4
wp-includes/ms-blogs.php:527switch_to_blog()wp-includes/ms-blogs.php:587switch_to_blog()wp-includes/ms-blogs.php:621restore_current_blog()wp-includes/ms-blogs.php:682restore_current_blog()
Source code
* * @param int $new_blog_id New blog ID. * @param int $prev_blog_id Previous blog ID. * @param string $context Additional context. Accepts 'switch' when called from switch_to_blog() * or 'restore' when called from restore_current_blog(). */ do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' ); $GLOBALS['switched'] = true; return true; }Changelog
Introduced in 5.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.4.0
The
$context parameter was added.from the docblockMU (3.0.0)
MU (3.0.0)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.