Hi all,
I am writting my first plugin. When I try to globalize the $wpdb object from an internal WordPress multisite dashboard (the code is embedded in the dashboard page), it works, i.e., I can run "$wpdb->blogid", and it shows the current blog ID, different depending which blog dashboard i run it from.
But when I run this "$wpdb->blogid" from an external script, triggered from a dashboard button, it always shows blogid = 1, whatever the blog I run it from.
This is the script:
<?php
define('__ROOT__', dirname(dirname(dirname(dirname(__FILE__)))));
require_once(__ROOT__.'/wp-load.php');
global $wpdb;
$ident = $wpdb->blogid;
$pref = $wpdb->prefix;
echo $ident;
echo $pref;
echo get_site_url( get_current_blog_id() );
?>
I am becoming crazy! If I run it from inside a WordPress dashboard, it shows the right blog ID, and the prefix like "wp_#". But If I run it as a external script, it always shows blogid = 1, and prefix = "wp_".
It seems that when $wpdb gets globalized, it gets configured as if it was the main site...
Any help is appreciatted!! thank you