Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-settings.php on line 264

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-settings.php on line 266

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-settings.php on line 267

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-settings.php on line 284

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-includes\cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-includes\query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in D:\kiranthomman.com\wwwroot\wp-includes\theme.php on line 540
Kiran Thomman » Wordpress

Archive for the ‘Wordpress’ Category

Setting single login across multiple Wordpress 2.7 installs using a single domain

Wednesday, April 29th, 2009

I am in the process of launching a community website. It’s requires different sections including a forum. The best way of handling it was to use different instances of Wordpress for each section. This way I could use separate themed templates for each install. Although each section especially the forum would have its own unique set of visitors some of them tend to be shared across the other sections. It really wouldn’t appeal to visitors to login or register to each section separately to each section of the site. So ideally the user profile has to roam across all sections of the site using a single registration or login from any section.

A quick search on Google revealed that its possible. Most of the posts I researched were helpful put could only partially solve the problem. The first post Setting up a common login across multiple wordpress installations claimed to solve the issue only helped me in allowing the different sections to use the same login as the main site. The reason it probably  worked for the writer was that the other steps too were incorporated earlier but not for the specific purpose of a common login which he did not consider. The second post Multiblog single login in WP 2.6 gave an idea as to how it could be accomplished but in 2.6. However it is the final post Múltiples (WordPress + bbPress + MediaWiki) en uno that actually helped me and covered all the steps but this is in Spanish and I had to use Babelfish to understand what he was sharing. So the pupose of this post is to provide an english version of the last post or probably a summation of all three as I feel this is something that could come in very useful to other wordpress blog users who would want to do something similar.

I am not a hardcore Wordpress user and this personal blog is the only one I have formally worked on till now. So I am a novice to the whole thing. I’m telling you this to let you know that its not a big deal to get it all working when the people and posts above have enlightened you on how to go about it.

Although my actual url is different I am testing temporarily using my site kochidaily.com. And for the purpose of explanation we will be using this website. The first step is to install the multiple Wordpress blogs. I have now set up two blogs one accessible at www.kochidaily.com and the other at www.kochidaily.com/jobs . Both the blogs use a single database. However at the time of install I have set the prefix of the table for the main database as cd_ and the jobs database as jobs_. After this I ended up with two blogs with independent logins.

The next step is for www.kochidaily.com/jobs to use the same login as the main site www.kochidaily.com. This was accomplished by editing two files in the second blog ie is the jobs. First I edited wp-config.php after the line /* That’s all, stop editing! Happy blogging. */
with

define(’CUSTOM_USER_TABLE’, ‘cd_users’);
define(’CUSTOM_USER_META_TABLE’, ‘cd_usermeta’);

After this I opened capabilities.php in wp-includes and modified the section after Setup capability object properties to

function _init_caps() {
global $wpdb;
// $this->cap_key = $wpdb->prefix . ‘capabilities’; /* original code */
$this->cap_key = ‘cd_capabilities’; /*modified code */
$this->caps = &$this->{$this->cap_key};
if ( ! is_array( $this->caps ) )
$this->caps = array();
$this->get_role_caps();
}

After this I was able to log in to both blogs using the logins from the main site but had to login and logout individually.

Now I have to share logins across both sites this is achieved by making the cookie information across sites is the same. In the wp-config file I navigated to the section specifying Authentication Unique Keys. I generate unique keys by using the URL https://api.wordpress.org/secret-key/1.1/ as specified in that section. I replace the authentication keys for all wp-config files with the same lines so that they remain the same for each blog. My final lines for wp-config placed under authentication keys is as follows.

define (’COOKIE_DOMAIN’, ‘.kochidaily.com’);
define(’COOKIEPATH’, ‘/’);
define(’AUTH_KEY’, ‘j7z/~e9,G3=WY*plq^2b9_E1qgf-N< dxJD>)]+J5-[v’);

define(’SECURE_AUTH_KEY’, ‘unt&N4$hw;qmt3VEY*_=(7-3N)*9[~v4–Y#s*k&fqsR7va*h}WHyQAwf{=+;?C-’);

define(’LOGGED_IN_KEY’, ‘B%K&JbF?_=Ft6N`WvZ+&*SbW::x8AhNL5_Gs$/(oAsLY1,D1JlaF#a$/DRNfy[qV’);

define(’NONCE_KEY’,  ‘KFOYq&kB[D?2J~ ;W:zSbn#$hDm{_6<p|T^/}1d4^%N HC7m3jc[-|(38~ |P+lh’);

$baseurl = ‘http://www.kochidaily.com’;
$cookiehash = md5($baseurl);
define(’COOKIEHASH’, $cookiehash);
define (’AUTH_SALT’,'AUTH_SALT’.COOKIEHASH);
define (’LOGGED_IN_SALT’, ‘LOGGED_IN_SALT’.COOKIEHASH);
define (’AUTH_COOKIE’, ‘AUTH_COOKIE’.COOKIEHASH);
define (’SECURE_AUTH_COOKIE’, ‘SECURE_AUTH_COOKIE’.COOKIEHASH); // If you use connection SSL
define (’LOGGED_IN_COOKIE’,'LOGGED_IN_COOKIE’.COOKIEHASH);
define (’TEST_COOKIE’, ‘TEST_COOKIE’.COOKIEHASH);

As you can see there are other cookie values than what you see by default. This too needs to be shared so I appended it below the shared Authentication keys in order for the logins to be shared. I have used an md5 of $baseurl which is set to the site name you can modify it to any phrase of your choice. Well thats it I fired my browser cleared all cookies previously set (for testing) I logged into the main site and then shifted to the jobs site and voila! I was logged in there too!