switch_blog

switch_blog

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: action
See hook in action

See hook in core

Displaying hooks found in version: wordpress-6.7

do_action('switch_blog') is found 4 times:

  • /wp-includes/ms-blogs.php line 522
    		 * @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;
    	}
    
    
  • /wp-includes/ms-blogs.php line 582
    		}
    	}
    
    	/** This filter is documented in wp-includes/ms-blogs.php */
    	do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' );
    
    	$GLOBALS['switched'] = true;
    
    	return true;
    }
    
    
  • /wp-includes/ms-blogs.php line 616
    	$prev_blog_id = get_current_blog_id();
    
    	if ( $new_blog_id === $prev_blog_id ) {
    		/** This filter is documented in wp-includes/ms-blogs.php */
    		do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );
    
    		// If we still have items in the switched stack, consider ourselves still 'switched'.
    		$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
    
    		return true;
    	}
    
  • /wp-includes/ms-blogs.php line 677
    		}
    	}
    
    	/** This filter is documented in wp-includes/ms-blogs.php */
    	do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );
    
    	// If we still have items in the switched stack, consider ourselves still 'switched'.
    	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
    
    	return true;
    }
    

See this hook used in plugins: