Notice: "Post Meta" is not a supported wp_template_part area value and has been added as "uncategorized". in /home/ev3rywh3re/swampthings.org/wp-includes/block-template-utils.php on line 219

Notice: "Post Meta" is not a supported wp_template_part area value and has been added as "uncategorized". in /home/ev3rywh3re/swampthings.org/wp-includes/block-template-utils.php on line 219

Notice: Undefined index: wp_global_styles in /home/ev3rywh3re/swampthings.org/wp-content/plugins/wordpress-mu-sitewide-tags/sitewide-tags.php on line 347
Using HyperDB to separate and share user and user_meta between WordPress installations – Notes & Stuff

Using HyperDB to separate and share user and user_meta between WordPress installations

I need to remember to keep this example for some testing. This should be a good start for sharing a user and user_meta between websites. I do know that user_meta tends to have very site-centric settings at times. Original article was located at: http://wordpress.aspcode.net/view/63538464303732726666099/how-to-use-hyperdb-to-separate-and-share-a-user-dataset-between-wordpress-installs

[code]
$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’;
}
}
[/code]

Leave a Reply

Your email address will not be published.