Saturday, July 17, 2010

How to login multiple word press sites with single login

If there is two or more than wordpress sites with in a main wordpress.Like child word press, and we wanna enter the admin of all sites with the single login
for this we need to add the code for using same user table for this we will add code in wp-config.php of child wordpress.
Suppose we have wp_users table in parent wordpress and wp_child_user for child wordpress. the idea is that we have to use same credentials for all wordpress. so we need to add code for to use the user table of parent wordpress
so open the wp-config.php of child wordpress.
define('CUSTOM_USER_TABLE','wp_users'); // shared user db
define('CUSTOM_USER_META_TABLE','wp_usermeta'); // shared usermeta
now replace the
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
line of both config.php files with
define('AUTH_KEY',        ')6ymo_O2f(?oF&Zm<#p+&UMlnrBpfKs]HL`@@uH}vt%]X(7&U@rw&`_;-M3xi])/');
define('SECURE_AUTH_KEY', 'sLh`1v7sZM-X#|%/0b<7OCX*UYyR{bmAVNZi=BZrU/<g/x -=8(Dv*~zb+G>q)$|');
define('LOGGED_IN_KEY',   'dQ;JHn8c(K!%[zi+lzd3<CfX9 z$~/<+M@qLt%Lq$|c%~6=X_9RN)SHIm=f5j<-i');
define('NONCE_KEY',       'OauPeHLGei#I_f**YiS!u!-|#|4^=}RKbs;oc8Ox[-XpULusT )C fT;X@<5}<FR');
define('AUTH_SALT', 'Oxiw7VX@XA5y$j$U^Ox^z$4682F2*sAI2yc@nvgZSikRZnJGmnz0EfulzMx0uBoO');
define('LOGGED_IN_SALT', 'p*d79LVP0b3l6&F0JixVYUrg&B&s&KNNqfn5gy2qXrBaw1MkBAypNkcEv$sz7i(T');
Now open the wp-setting.php file of child wordpress
and go to the line
define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
replace it with
define('COOKIEPATH','//');
Now go to
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
replace it with
define('SITECOOKIEPATH','//');
Now go to
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
replace it with
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . '' );
now go to
define('COOKIEHASH', md5(get_option('siteurl')))
replace it with
define('COOKIEHASH', md5())
Do the same for parent worpress's wp-setting.php file

Now open the wp-includes/capabilities.php file of child word press
goto the code:
function _init_caps() {
  global $wpdb;
 $this->cap_key = $wpdb->prefix . 'capabilities';
  $this->caps = &$this->{$this->cap_key};
  if ( ! is_array( $this->caps ) )
   $this->caps = array();
  $this->get_role_caps();
 }
and replace the 2nd line of the _init_caps with
$this->cap_key = 'wp_capabilities';

1 comments:

Anand said...

Nice Post

Once again Very Helpful in my work
Keep Posting
Waiting for your Another Miracles

Anand

Post a Comment