Results 1 to 3 of 3

Thread: How to share WordPress user accounts across multiple blogs

  1. #1
    Founder dcowgill's Avatar
    Join Date
    Mar 2009
    Location
    San Francisco, CA
    Posts
    1,939
    Thanks
    66
    Thanked 135 Times in 99 Posts

    How to share WordPress user accounts across multiple blogs

    Sharing WordPress accounts across multiple blogs is possible as of WordPress v2.6. This enables people to register on either one of your blogs and only have one account (username/password) to manage.

    I've seen this question asked before and thought it would be helpful to write a tutorial about it. I personally prefer keeping the user accounts separate for added security and easier account management since I'd be the only one with access to my primary blog. It's up to you how you'd like to setup your sites though.

    Example: This would be useful for someone running two instances of WordPress one of which is ClassiPress in a sub-directory of your primary WordPress site.

    http://www.your-main-site.com" <-- your main instance of wordpress running the a different theme
    http://www.your-main-site.com/classipress" <-- another instance of wordpress running classipress

    So how can you do this? If you're starting out fresh and haven't yet installed a secondary blog, then this will be much easier. If not, you'll have to migrate your secondary database into your primary database (which is another tutorial).

    1. Make sure you are using WP v2.6 or greater
    2. Both WordPress instances must be in the same database
    3. Add custom defines to the wp-config.php of your secondary (child) blog

    Let's assume your primary blog was installed with a table prefix of "wp_" and the secondary one with "wp2_". You'll then want to add the following code in wp-config.php of the secondary installation.

    Code:
    define('CUSTOM_USER_TABLE', 'wp_users');
    define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
    Install it right above the following line:
    Code:
    /* That's all, stop editing! Happy blogging. */
    Now you are pointing your secondary blog to the primary WordPress user tables.

    You can technically do this for as many instances of WordPress as you like but the key is to make sure they are all installed on the same database otherwise they won't be able to communicate. I'd also recommend making sure your versions of WordPress are in sync as well.

    Some of you might get a "You do not have sufficient permissions to access this page" error message which means you are probably trying to do this across different domains. If you have a sub-directory like in the example above, it shouldn't be a problem.

    From what I read online, you'll need to add this line to wp-config.php of your secondary blog right below the other two entries you added above.
    Code:
    define('CUSTOM_CAPABILITIES_PREFIX', 'wp_');
    Then you'll also need to modify a core WordPress file wp-includes/capabilities.php (which I don't think is a good idea b/c you'll have to update it everytime you upgrade WP)

    Replace the following
    Code:
    $this->cap_key = $wpdb->prefix . 'capabilities';
    with
    Code:
    if (defined ('CUSTOM_CAPABILITIES_PREFIX')) {
    	   $this->cap_key = CUSTOM_CAPABILITIES_PREFIX . 'capabilities';
    	} else {	
               $this->cap_key = $wpdb->prefix . 'capabilities';
    	}
    I have not personally tried this yet so I cannot provide any support if it doesn't work. If you do have questions either search Google or checkout the WordPress support site. Usually your question has been answered already.

  2. #2
    Member egghead's Avatar
    Join Date
    Aug 2009
    Posts
    62
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: How to share WordPress user accounts across multiple blogs

    My classipress site is set up with a main domain (not the classipress) as the landing site and then five subdomains (with the classipress) for different geographic regions.

    I'd like to open this up for discussion, because it's something that we're wrestling with at the moment and it would be great to have some feed back.

    First off, is this type of modification possible for us to have User access to all of the sub-domain sites and not the main domain?

    And then, do we want to do this. I agree with Dave, in his post above. Having the User register for each site does give us a bit more control over what's going on in our service. It doesn't really prevent anything, because if someone is really intent on posting to every region they still can. But we can then remove the excess Ads, if we feel they are spammy.

    The issue is for the dude who lives on the border of two regions. Of course we're not going to stop him from posting on more than one site (in fact it'll help us in the short run if he does), but it's a bit of a pain in the but for him to register twice. Customer service is so important... what do you think?
    ... standing on the shoulders of giants

  3. #3
    buddy62's Avatar
    Join Date
    Oct 2009
    Location
    Malaga, Spain
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: How to share WordPress user accounts across multiple blogs

    My site (www.gone2market.com) has 5 sub-domains too, but not for geographical reasons, I have seperated them into main sections FREE ads/Auto/Homes/Jobs/Services and Adult. I split these up like this so that:
    (1)I can have more specific advertising on each sub-domain
    (2) I can shut the individual sites down for maintenance/upgrades without upsetting the others.
    (3) I wanted to keep the "Adult" section from being mixed in with the others (Categories/tags etc).

    I have shared the login across all the domains, but am still not able to log into one, and be logged in to all, I know there is a way, and I have tried various methods from different sources, but none have worked for me.......yet, if there is anyone out there who has a fix for this, it would be much appreciated.

    Its a bit of an "Egg/Chicken" situation as I am also finding now, that I would like to build in a global search and to be able to post an ad into the main sections from a landing page???? is this possible??? I have only been using wordpress for a few weeks now and this is waaaaaay over my head at the moment, but don`t think that I have done too bad so far!!!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Looking for a wordpress plugin
    By bili.ph in forum ClassiPress General Discussion
    Replies: 3
    Last Post: August 5th, 2011, 05:25 PM