Action hook 'switch_blog'

in WP Core File wp-includes/ms-blogs.php at line 682

View Source

switch_blog

Action Hook
Description
Restores the current blog, after calling switch_to_blog().

Hook Information

File Location wp-includes/ms-blogs.php View on GitHub
Hook Type Action
Line Number 682

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into switch_blog
add_action('switch_blog', 'my_custom_function');

function my_custom_function() {
    // Your custom code here
}

Source Code Context

wp-includes/ms-blogs.php:682 - How this hook is used in WordPress core
<?php
 677  			wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) );
 678  		}
 679  	}
 680  
 681  	/** This filter is documented in wp-includes/ms-blogs.php */
 682  	do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );
 683  
 684  	// If we still have items in the switched stack, consider ourselves still 'switched'.
 685  	$GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
 686  
 687  	return true;

PHP Documentation

<?php
/**
 * Restores the current blog, after calling switch_to_blog().
 *
 * @see switch_to_blog()
 * @since MU (3.0.0)
 *
 * @global wpdb            $wpdb               WordPress database abstraction object.
 * @global array           $_wp_switched_stack
 * @global int             $blog_id
 * @global bool            $switched
 * @global string          $table_prefix       The database table prefix.
 * @global WP_Object_Cache $wp_object_cache
 *
 * @return bool True on success, false if we're already on the current blog.
 */
Quick Info
  • Hook Type: Action
  • Parameters: 0
  • File: wp-includes/ms-blogs.php
Related Hooks

Related hooks will be displayed here in future updates.