switch_blog WordPress Action Hook

The switch_blog hook is one of the most useful hooks in WordPress. It allows you to change the blog ID while a user is logged in. This can be very helpful if you have multiple blogs and want to switch between them.

do_action( 'switch_blog', int $new_blog_id, int $prev_blog_id, string $context ) #

Fires when the blog is switched.


Parameters

$new_blog_id

(int)New blog ID.

$prev_blog_id

(int)Previous blog ID.

$context

(string)Additional context. Accepts 'switch' when called from switch_to_blog() or 'restore' when called from restore_current_blog().


Top ↑

Source

File: wp-includes/ms-blogs.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
MU (3.0.0)MU (3.0.0)
5.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.