switch_blog

Fires when the blog is switched.

Description

do_action( 'switch_blog', (int) $new_blog, (int) $new_blog ); 

Parameters (2)

0. $new_blog (int)
The new blog.
1. $new_blog (int)
The new blog.

Usage

To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'switch_blog', $new_blog, $new_blog ); 
The following example is for adding a hook callback.
  1. // define the switch_blog callback 
  2. function action_switch_blog( $new_blog, $new_blog ) { 
  3. // make action magic happen here... 
  4. }; 
  5.  
  6. // add the action 
  7. add_action( 'switch_blog', 'action_switch_blog', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'switch_blog', 'action_switch_blog', 10, 2 ); 

Defined (4)

The action is defined in the following location(s).

/wp-includes/ms-blogs.php  
  1. do_action( 'switch_blog', $new_blog, $new_blog ); 
  1. do_action( 'switch_blog', $new_blog, $prev_blog_id ); 
  1. do_action( 'switch_blog', $blog, $blog ); 
  1. do_action( 'switch_blog', $blog, $prev_blog_id );