问题已解决。以下是我所做的:
$wpdb->add_database(array( //Connect to Users Database
\'host\' => DB_HOST, // I am using the same host for my two DBs
\'user\' => DB_USER, // I am using the same username for my two DBs
\'password\' => DB_PASSWORD, // I am using the same p/w for my two DBs
\'name\' => \'my_user_db_name\',
\'write\' => 0, // Change to 1 if you want your slave site\'s the power to update user data.
\'read\' => 1,
\'dataset\' => \'user\',
\'timeout\' => 0.2,
));
$wpdb->add_database(array( // Main Database
\'host\' => DB_HOST,
\'user\' => DB_USER,
\'password\' => DB_PASSWORD,
\'name\' => DB_NAME,
));
$wpdb->add_callback(\'user_callback\');
function user_callback($query, $wpdb) {
if ( $wpdb->base_prefix . \'users\' == $wpdb->table || $wpdb->base_prefix . \'user_meta\' == $wpdb->table) {
return \'user\';
}
}
请注意,如果插件对您的管理权限进行了调整(我有一个这样做的),那么您连接的站点也必须进行调整。
我见过几个人有这样的问题:如何在不使用相同DB的情况下在Wordpress安装之间共享用户?有了HyperDB,我就能解决这个问题!