Hi all,
We're using HyperDB plugin to share the wp_users table across multiple, non-Multisite WordPress 3.2.1 instances. Each instance uses its own database for all of its tables, except for wp_users, which is placed in a shared database.
Everything works fine except when WP tries to run a query that joins the wp_users and wp_usermeta tables. It returns 0 rows when that happens.
In the UI, this happens if you go to:
/wp-admin/users.php?role=administrator
Or edit a post and see that the "change author" select list doesn't appear.
It seems that both of these features use a query which does a join explained like above.
One query I've isolated is the following:
SELECT SQL_CALC_FOUND_ROWS wp_users.ID FROM wp_users INNER JOIN wp_usermeta ON (wp_users.ID = wp_usermeta.user_id) WHERE 1=1 AND ( (wp_usermeta.meta_key = 'wp_capabilities' AND CAST(wp_usermeta.meta_value AS CHAR) LIKE '%\"administrator\"%') ) ORDER BY user_login ASC LIMIT 20;
Here is the relevant info from db-config.php:
// Add global/main DB for this specific site
$wpdb->add_database(array(
'host' => $db_host,
'user' => 'db_user',
'password' => 'db_pass',
'name' => 'db_main',
));
// Use db_users DB for wp_users table; this enables us to share the wp_users
// table across non-MU, non-multisite instances.
$wpdb->add_database(array(
'host' => $db_host,
'user' => 'db_user',
'password' => 'db_pass',
'name' => 'db_users',
'dataset' => 'users',
));
$wpdb->add_callback('add_shared_users');
function add_shared_users($query, $wpdb) {
if ($wpdb->base_prefix .'users' == $wpdb->table) {
return 'users';
}
}
One more detail: If I move the wp_usermeta into same database as wp_users, the above query does return the correct number of rows. So, as a fallback, I could put each site's wp_usermeta table into the shared database.
Is what I'm trying to do possible with HyperDB? Or is there a better method for sharing wp_users table across multiple, non-Multisite WP3 instances?
Thanks for any input!
-Chris