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.2

do_action('switch_blog') is found 4 times:

  • /wp-includes/ms-blogs.php line 522
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
         * @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
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
            }
        }
     
        /** 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
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    $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
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
            }
        }
     
        /** 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: