Support » Installing WordPress » Sharing user accounts between seperate blogs in the same database

  • I’ve just read this useful thread from last year. It’s sort of what I want to do, but not quite: I’m trying to create an internal blog only available to registered users. This means sharing registered user info between each set of tables. Looking at this bug ticket it is possible, but I can’t find any details on how to do it.

    Any help appreciated!

Viewing 15 replies - 1 through 15 (of 16 total)
  • Assuming you’ve installed your internal blog with different table prefixes in the same database as your public blog (say ‘wp_internal_’ for the internal, and just ‘wp_’ for the public), then you can add these lines to your internal blog’s wp-config.php file:


    Those lines need to appear before require_once(ABSPATH.'wp-settings.php');

    I forgot to mention that if you want users to stay logged in across the two blogs, you should add the following two lines:

    define('USER_COOKIE', 'wordpressuser_'. [public site's cookie hash]);
    define('PASS_COOKIE', 'wordpresspass_'. [public site's cookie hash]);

    You can see the public site’s cookie hash in your cookies, or render it with the following, where “siteurl” is the value under Options > General > “WordPress address (URI):”

    the cookie hash = md5(siteurl);

    so you’d have something like

    $public_cookiehash = md5('');
    define('USER_COOKIE', 'wordpressuser_'. $public_cookiehash);
    define('PASS_COOKIE', 'wordpresspass_'. $public_cookiehash);

    Thanks, that’s just what I need. Where does the cookie code go – before require_once like the user tables lines?

    Something else just came into my mind: can I use the same FTP files from both blogs? I can’t think of anything that would prevent that, except for wp-config.

    Thanks, that’s just what I need. Where does the cookie code go – before require_once like the user tables lines?

    Yeah, just put it after the other stuff I mentioned earlier.

    can I use the same FTP files from both blogs?

    You mean the WordPress installation files? Sure. You are installing the internal blog in a separate directory, right?

    That’s what I’m asking – can the two blogs use the same wp-content, wp-admin, etc. folders on the server? You seem to suggest that it can’t though.

    Right, they can’t use the same files on the same server. But because you said “FTP files” I thought you were asking if you could reuse the WP files in the installation zip file, which of course you can. But your two blogs will need to be in separate directories.

    I’m getting an error stating that I already have WP installed. True enough, but not not terribly useful in this situation! I’ve set up the login details correctly, and I am using a unique table prefix (unless somebody I can’t see on the DB has chosen ninja_ too).

    Any ideas?

    Install the internal blog before adding the changes I mentioned above, then put them in.

    OK, I’m up and running! Slight hitch with permissions, as the admin account from the parent blog wasn’t an admin in the new one, but logging into WP’s default account before inserting the wp-config code sorted that out easily enough.

    Thanks for the help!

    Actually, one last glitch. If you log in to the sub-blog, you aren’t logged in to the main site. I would expect logins from either location to apply to both blogs. Any way to close that loophole?

    You did the cookie settings as I suggested above?

    If you log out of both, then log into the main blog, can you access the sub-blog?

    Yes, it’s in there and works as you describe. It’s just that while logins on the main site work for the sub-blog, the opposite isn’t true.

    My bad. Try adding this after the other stuff above:


    or it might need to be




    Hi, i’m trying to realise the same thing, and after following the instructions above it works partially.

    If I login on the first blog (who’s user tables are shared) everything works fine. When I go to the second blog I’m already logged in.
    So far so good.

    But logging out doesn’t work since I get a message that I’m not allowed to access blogname/wp-admin/profile.php
    I can enter the admin, but only the first page.

    This seems to be a problem with wp_usermeta, but I did define that one as well as wp_users.

    Can anyone help me with this?

    $public_cookiehash = md5(‘’);
    define(‘USER_COOKIE’, ‘wordpressuser_’. $public_cookiehash);
    define(‘PASS_COOKIE’, ‘wordpresspass_’. $public_cookiehash);

    I’m trying to do the same thing. The above code works for the second blog, or 1st child blog (if you want to call it that) fine, but doesn’t work when I’ve put it in the wp-config files of other additional blogs. Any ideas?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Sharing user accounts between seperate blogs in the same database’ is closed to new replies.