[wp-hackers] Re: Re: Sharing Users/authentication

Curt Woodard clwoodard at gmail.com
Tue Aug 28 16:52:44 GMT 2007

OK, well, getting two copies of WordPress to work together was a
little tricky but I have successfully set up two test installations of
WordPress 2.2.2 and wrote a plugin that does this:

* 'Slaves' one copy of WordPress to a 'Master' copy.
    * Tie the Slave's $wpdb->users and $wpdb->usermeta tables to the Master's
    * Match the Slave's USER_COOKIE and PASS_COOKIE to the Master's

* The administrator need only modify 3 variables in the plugin:
$this_role, $my_master_db,
  and $my_master_prefix. $this_role tells WordPress if the copy is a
slave or a master and the
  other two are pretty self-explanatory.

* Promotes concurrent login between the two installations (due to the
cookie redefine).

* The plugin is meant to be installed and activated on both the slave
and the master copies
  of WordPress to get the concurrent login to work.

* With this plugin, you can slave any number of WordPress installs to
one user and
  usermeta table.

I've tested this and it works pretty well :)

Now, there are a few things to note:

* In wp-includes/user.php, there is a function that isn't referenced
anywhere: get_profile.
  This function looks at USER_COOKIE but may be deprecated.

* To make things work well, the usermeta table had to be shared as
well so that the admin
  of the Slave copy was also the admin of the Master copy. This is
also necessary due to
  how WP uses the usermeta table when updating profiles. Better to
have one copy of the
  user's settings than to have multiple copies.

* I might have to put in code that overrides the COOKIEPATH and COOKIE_DOMAIN as
  well. So that you can set up subdomain-free cookies.

You can download the plugin from http://www.lyonesse.info/WPP/ (a
simple, crude, yet effective page).


More information about the wp-hackers mailing list