Don't perform current user ops in switch_to_blog() or restore_current_blog() if init hasn't fired. Avoids wp_get_current_user() not defined error when those functions are run before init. Ops on current user prior to init are meaningless anyway. see #13934
git-svn-id: http://svn.automattic.com/wordpress/trunk@15331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b3c30fe1ff
commit
6c31f32be1
|
@ -407,9 +407,11 @@ function switch_to_blog( $new_blog, $validate = false ) {
|
|||
$wpdb->suppress_errors( false );
|
||||
}
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->for_blog( $blog_id );
|
||||
if ( ! did_action('init') ) {
|
||||
$current_user = wp_get_current_user();
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->for_blog( $blog_id );
|
||||
}
|
||||
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
|
@ -461,9 +463,11 @@ function restore_current_blog() {
|
|||
$wpdb->suppress_errors( false );
|
||||
}
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->for_blog( $blog_id );
|
||||
if ( ! did_action('init') ) {
|
||||
$current_user = wp_get_current_user();
|
||||
if ( is_object( $current_user ) )
|
||||
$current_user->for_blog( $blog_id );
|
||||
}
|
||||
|
||||
if ( is_object( $wp_object_cache ) && isset( $wp_object_cache->global_groups ) )
|
||||
$global_groups = $wp_object_cache->global_groups;
|
||||
|
|
Loading…
Reference in New Issue