switch_to_blog() not working
-
I am currently writing a plugin for Multisite, and in it, I need to switch to the blog that is using the plugin.
$blog_id = $_POST['blog_id']; switch_to_blog($blog_id); // PLUGIN DOES STUFF restore_current_blog();
In the above code, I’ve verified that $blog_id is the id of the blog I need (in this case, it’s 37). The value returned from the switch_to_blog function is ALWAYS 1, and the plugin does stuff to blog id 1.
$wpdb->set_blog_id($blog_id); // PLUGIN DOES STUFF restore_current_blog();
This code switches to the desired blog id.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘switch_to_blog() not working’ is closed to new replies.