User Sync Plugin not working for me

I have a main Wordpress install on one domain, and two additional installs on subdomains of that domain. I've gone through the steps of putting the plugin on all three installs, and using the main as master and the others synced with main. When i try to login to the subdomains using an ID I know to be on the main, it fails. Further (and I find this strange), I looked into the database, and the user tables are duplicated across the installs (i.e., inside each distinct prefix), so i can't imagine why i can't login.

Any help with this?

I'm running the latest version of Wordpress, 3.2.1

  • immanence

    Correction: only one of the subdomain sites has the users in both the backend and the database. The other one has only me as a user, and same in the backend. So I guess it failed to sync.

    Seeing this I tried to sync the two sites again in the User Sync pane of the main site. It ran for quite a while (I have around 700 users) and in the end redirected me to a 404 Page Not Found error.

    These are the plugins installed on the main (Master) install:

    url-shortener user-sync

  • immanence


    I tried what you said. I set a simple password in the users table of the one sub site that shows up users and refreshed the sub site. Logging in failed. Same error of unknown user.

    What I don't understand is why this plugin is reproducing the user table at all. Surely a more elegant solution is just to map the sub sites to the main user table? This would also solve the problem of one-way or two-way syncing. In effect, there'd only be one user table, so anyone signing up on a sub site would be signing up on the main site, in fact.

    I hope the developer can chime in on this thread.

    It seems such an essential functionality for Wordpress. I wish a solution was possible.

  • Jonathan

    are both in the same database albeit on different prefixes

    immanence, I apologize profusely as I haven't read your previous posts, and don't have much experience with user-sync-plugin.

    I just happened to catch that you are sharing database. I thought the whole reason for user-sync was for individual sites that didn't share a database. ????
    If the plugin requires you have to share a database, then that sucks :slight_frown:

    Then you had might as well use mu, which you obviously don't want too?
    The only other option would be to rather use wordpress's built in system - wp-config file and define the user tables? That way you get one set of tables for all your sites.

    define('CUSTOM_USER_TABLE', $table_prefix.'my_users');
    define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');

    The login is a little more complicated though. Salts etc.

    Question: Is sharing a database a prerequisite for using user sync plugin?
    If it is, that blows my hopes of using it in a future project :slight_frown:

  • immanence

    FYI. I tried again, just for the hell of it, deactivating the plugin on all three sites, reactivating and going through the sync process. On one of the sub sites it failed. Connection error. This was the sub site that has all the users copied previously to the Dashboard / Users and were present in the database user table. Other reported success, but shows no users in the Dashboard, or in the database user table.

    On the sub site that failed, I went to the user table in the database and deleted all the present users, except me as admin.

    I went "Remove all Settings" in User Sync pane on that site, and re-inputted by the URL and Key. Same error: "There was a connection problem. Please check the URL and Key of the Master site."

    Checked the database. All users present again under that sub site's users table.

    Go figure.

    Logged out. Logged back in as another user whose password I know. "ERROR: Invalid username. Lost your password?"

    Went to database. Dumped the md5 hash. Put simple password in its place. Tried logging in again: "ERROR: The password you entered for the username ********* is incorrect. Lost your password?"

    At least it recognized the username.

    Tried replacing the password in the Master user table. Same error.

    Tried logging in to the site that returned a successful sync message: "ERROR: Invalid username. Lost your password?"

    Checked for error logs in cPanel. NONE.

  • immanence


    I don't think sharing the database is a prerequisite, but at the same time I don't think sharing it breaks the plugin (if I understand correctly).

    I have tried the other solution you mentioned: wp-config.php mods. But I just couldn't get it to actually work. That's why I'm here trying this plugin.

    MU sounds great, but my experience with it in practice was a nightmare. I won't go there again.

    If anyone has a walk-through for the wp-config.php solution, I'd love to see it. The ones I found online were either incomplete, or obtuse, and whatever I did to try to make them work didn't work.

  • Mason

    Hiya @immanence

    I've alerted the developer to this thread specifically. He'll respond as soon as he's able. Have you tried other usernames or are you always attempting the same one... maybe something's corrupted for that username.

    Note: @jonathan, no you don't have to have the same database. It's really designed for separate databases - though I don't see how it would cause an issue for @immanence's seetup.

    When was the last time you tried multisite? I know that's not directly related to this thread but I'm curious as to the issues you had. I have several multisite installs and we run with over a million sites fairly well. If you're creating several installs on different subdomains and sharing a database with custom prefixes... you're pretty much doing exactly what multisite does.


  • immanence


    I've tried several usernames, yes. And also created new usernames and tried those.

    On multisite, I really like the idea, but in practice there are two issues for me: 1) not all WP plugins appear to work with multisite. This is a near deal breaker, because I put functionality for the end user over ease of use for the developer; 2) It is (or I found it so) difficult to pull in an existing site into multisite. Plugins that help you clone sites don't work in multisite, and it quickly gets too complicated for my already strained head.

    In reality, I don't really need multisite. Mostly I just wish that a WP single install could put content on a subdomain, and above all I wish I could section out content and serve different themes according to sections.

    Right now, the project I'm working on is for a newspaper. I have one theme that handles text very well, for the main site, and I also have two subdomains running: one running a theme that does a beautiful job of handling a jobs board, and another that does a decent job of handling a classifieds site. For me, all of these should be running off one install. But multisite is really not designed for *that* in particular. It's really designed for something else: multiple distinct blogs.

    I trust that Wordpress will continue to develop. It has come on in leaps and bounds in the last three years. Eventually I'd hope that the distinction between Wordpress and Wordpress multisite can fade into the background, and that the backend would be robust enough out of the box to deal with many real world situations.


  • immanence
    define('CUSTOM_USER_TABLE', $table_prefix.'my_users');
    define('CUSTOM_USER_META_TABLE', $table_prefix.'my_usermeta');

    Can someone explain this to me?

    I thought it was enough to put only the name of the master users table, but here I see $table_prefix. before that. What is this? What value should this be? is it the master table prefix, or the sub site table prefix?

    Say, for example, I have three sites:

    Master: $table_prefix = wpmaster1_
    user table name = wpmaster1_users
    user meta table name = wpmaster1_usermeta

    Sub site 1: $table_prefix = wpsub1_

    Sub site 2: $table_prefix = wpsub2_

    What would be the configuration of Custom User Table and Custom User Meta Table that I would have to add to each sub site wp-config.php to get them to read from the master user table / metatable?

    For example, the code for sub site 1 should be:

    define('CUSTOM_USER_TABLE', $wpmaster1_.'wpmaster1_users');
    define('CUSTOM_USER_META_TABLE', $wpmaster1_.'wpmaster1_usermeta');


    define('CUSTOM_USER_TABLE', $wpsub1_.'wpmaster1_users');
    define('CUSTOM_USER_META_TABLE', $wpsub1_.'wpmaster1_usermeta');

    or something else ??

  • immanence

    If I understand things well, if I get the answer to my last question I won't need the plugin, and indeed the solution would be better than the plugin, because anyone registering on a sub site would actually be inputting into one user table. Hence it would be two-way. The only problem, I understand, is orphaned users. But there is a plugin that works to assign orphaned users a role:

  • Jonathan

    the default prefix is wp_
    Your primary site you changed the wp_ to wpmaster1_ - correct?
    The database table for primary site is wpmaster1_users / and / wpmaster1_usermeta
    So it will look like this.

    define('CUSTOM_USER_TABLE', 'wpmaster1_users');
    define('CUSTOM_USER_META_TABLE', 'wpmaster1_usermeta');

    This $table_prefix.'my_users') = wpmaster1_my_users but the user table isn't my_users its users.
    So it is wpmaster1_users

  • immanence


    Thanks for clearing that up.

    Well, that's what I've been doing and it doesn't work for me.
    It makes sense that these custom values simply point to the name in the database of the tables you want the sub sites to read from.

    For some reason my sub sites aren't reading from them. I should see all my main site users in the Dashboard / Users of the sub sites. I see only me.

    In my attempt to get this going I followed this very solid tutorial:

    But it just doesn't work.

  • Jonathan


    It's been awhile since I did that setup. So sorry for asking such a obvious question, but you only added the

    define('CUSTOM_USER_TABLE', 'wpmaster1_users');
    define('CUSTOM_USER_META_TABLE', 'wpmaster1_usermeta');

    to your subsites wp-config.php files and left the primary site wp-config.php as is.

    And there is something else, I can't put my finger on it. Let me quickly do a test install. Two sites. One primary. One secondary. One user / usermetar tables. To see if I remember.

  • Jonathan

    Wow, it's like riding a bike. lol.

    Okay just created two seperate sites. One database shared.
    I edited second sites wp-config.php with primary sites users / usersmeta
    And logged in as primary site admin. Bam - I don't have permission for secondary site.

    So I went to primary site usermeta mysql table and added myself as admin for secondary site and logged in perfectly.
    I can see all primary site users, but they don't have roles for secondary site. But they exist (thanks to user are now allowed to have no role)
    I can also edit in both primary / secondary and edits appear on each site (gotta love one user table system)
    So this set up works. If I remember the hard part is the user login - salt / cookies etc - ouch!

  • immanence


    Thank you!

    Yes, the primary site's wp-config.php is left untouched.

    For the purposes of an attempt to engineer a single login for all sites, I also copied the Salt values and Auth_Key values over to the two sub sites.

    Basically, I followed the tutorial I linked in my last message.

    Instead of hard coding the anti-orphaned users fix into WP Core, I'm using WP Orphanage on all sub sites, as instructed.

    It would be great if you could find a fix.

  • immanence



    "So I went to primary site usermeta and added myself as admin for secondary site" <------ How do you do that in the database exactly?

    Sigh. I just can't see what I'm doing wrong.

    The key setting is in wp-config.php. This is what points the secondary installs to the main install user tables / usermeta table.

    I can't see what would go wrong at this stage ....... yet no matter what I do, I can't see any users from the primary site.

    Should I delete the user tables (which only include me) in the database that otherwise would be associated with the secondary installs? Maybe their existence is overriding the Custom Table values somehow??

  • Jonathan

    Sorry its pretty late here. Grabbed a cup of coffee.

    Did some more testing - this works flawlessly (you hate me, I know)
    I even just tried to give users roles on secondary site - works perfectly (they are subscribers on both sites)

    To Answer your question

    "So I went to primary site usermeta and added myself as admin for secondary site" <------ How do you do that in the database exactly?

    I'm using phpmyadmin to view and manipulate the msql database
    your primary site the wpmaster1_usermeta - there is you
    wpmaster1_capabilities | a:1:{s:13:"administrator";s:1:"1";}
    That says you are admin of wpmaster1_
    To add you as admin to secondary sites you need
    everything the same except
    wpsub1_capabilites | a:1:{s:13:"administrator";s:1:"1";}

    I click on wpmaster1_usermeta and now that I am in there click insert and add user_id etc Basically just fill in the details

    Okay lets troubleshoot:
    Will get back to this - let me think quickly.

  • Jonathan

    Another question: Does it matter where in the wp-config.php file the additional code is added? I have it all down the bottom

    This is secondary wp-config.php

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'database');
    /** MySQL database username */
    define('DB_USER', 'username');
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    define('CUSTOM_USER_TABLE', 'primary_users');
    define('CUSTOM_USER_META_TABLE', 'primary_usermeta');
  • immanence

    I can't believe it! It actually really DOES matter where in the wp-config.php you put the custom user code. No one tells you that.

    I had all down the bottom. I move it up, to where you have it in your example, and BOOM. Users appear in my secondary install and I can login using one of their credentials.


    Now for the single LOGIN!

    Again, I will follow the principle that it matters what order the code is in!

    Thanks so much for leading me to this breakthrough!

  • Jonathan

    Lol - here I am typing up a full on troubleshooting guide. I refresh to check if you had any more questions I could add - and you've solved it already. lol

    Yeah, I hope the cookie aspect doesn't break anything.
    I'll report back with any insights or problems ..... There may be others who benefit from this thread, like I did. Thanks again

    It shouldn't - but in case you find things are wonky - delete your browser cookies - trust me. Cookies aren't fun, but at least you can wipe em from your browser and start with freshly baked one.

    Yes, please keep me posted - keen to see how you manage this. I'm more than happy to be the student - lol

  • Jonathan

    Do a search in phpmyadmin in wpmaster1_capabilities for user id 1 (or whatever your id is) this will bring all entries together for you. Have a look now and edit what needs editing. (print screen - to record current settings or however you want to keep a backup) just in case you lock yourself out the other sites :wink: I like to print the options - so I can refer to them later if I mess up. It doesn't hurt to backup the database too :wink:

  • immanence

    Status update:

    So I have three installs (one main, two subs) sharing one user table. It works great, but I'm trying to make it better yet. I want to be able to login once at any of these installs and be automatically logged in if I go to another install.

    I'm using Root Cookie (, the latest development version ( <------- download at the bottom of the window)

    I needed the latest version. The standard one created a fatal error.

    I also, following this tutorial -------> have the following code in non-main sites:

    $baseurl = ''; // replace with the actual domain name for your root site
    $cookiehash = md5($baseurl);
    define('COOKIEHASH', $cookiehash);
    define ('AUTH_COOKIE', 'wordpress_'.COOKIEHASH);
    define ('SECURE_AUTH_COOKIE', 'wordpress_sec_'.COOKIEHASH);
    define ('LOGGED_IN_COOKIE','wordpress_logged_in_'.COOKIEHASH);
    define ('TEST_COOKIE', 'wordpress_test_cookie');

    I put it just below my Salt and Auth_Key values in wp-config.php

    It says in that tutorial to only put this code on non-main sites. It seemed to help to put it in all site wp-config.php files.

    I'm also using WP Orphanage to try to assign roles to orphaned users in sub sites.

    This is what is happening right now:

    1. WP Orphanage doesn't seem to be working on one sub site. Users have no roles. On the other sub site, it works fine. The sub site that doesn't work is the one that had logged me out of my admin capabilities earlier, so it may have to do with the same prefix. Perhaps it is something particular to the theme I'm running there.

    2. Logging in to the main site does *not* lead to automatic login to the two sub sites (either individually or each alone). However, logging in to one of the sub sites will lead to be logged in to the other sub site (but not the main) if you refresh in the other site. Logging out in one of the sub sites logs you out in the other, so that works well.

    So basically, main is working independently, whereas the sub sites appear to be linked, in part.

    In conclusion:

    a) If anyone can suggest ways to iron out this situation, or things to check, I'm all ears.

    b) I'm abandoning the User Sync plugin. What I've managed to implement is better than the functionality it provides.

  • Jonathan


    I see you've been busy - lol.

    I read through the article carefully. I have a feeling it might not work with latest wordpress versions (I can't say for sure, as I haven't played around with this setup for a long long time), got lazy and use mu - but I think if a solution is to be found - it will be in the wordpress mu setup (mirroring those cookie settings). Also might want to check how user sync handles it? (there little cookie magic?)

    But, I'm afraid someone is going to have to tag me on this. I watch this topic with interest and if I find anything while I dig around abit I'll mention it :slight_smile:

    Edit: Can't find any cookie magic in user sync (weird thought it allowed user to be logged in across all synced sites). It is really just a sync plugin (I must be loosing my mind - I thought it had more functionality - I probably read into things and didn't actual read things - lol) Yeah, I think sharing user tables trumps syncing if you want to share a database. But, if you want seperate wordpress installs, seperate databases - then user sync is the better choice.

    Will have a look at how mu handles cookies, but can't promise anything. Hope someone with knowledge in wordpress cookie manipulation steps up...

  • immanence


    Exactly. Separate databases, there is some use to this plugin. Same database, there's very little use. At the same time, a caveat: as I understand it, the "syncing" is only one way (from main to sub sites). If a user registered in a sub site, those details (I believe) would not be synced back to the main site. So it's not really syncing as such.

    This lack of two-way conversation between sites is a flaw in the plugin's functionality, I think.

    On cookies: what about the Domain Mapping plugin?

    It says, "And, naturally, we've built in cross domain cookie syncing, so your users will stay logged in (or out) regardless of whether they are on your standard domain or their custom one."

    Would that work, and if so, what would be the configuration?


  • Jonathan


    That's great news about the domain mapping. It's a great plugin - looking forward to the nifty update :wink:


    On cookies: what about the Domain Mapping plugin?

    The code is all there to do what you need done. However, it is going to need some custom coding to get it to work on your setup. Actually it handles the cookie side pretty well. The only issue is generating the $key that is currently generated and saved into each domains options table. The plugin is very much mu, so you will either need someone to turn it into a manual process, or something ???.

    Trying to think outside the box - Why do you need user to be logged in across all sites? Don't think I even asked you that yet. There might be a simpler way? Depending on your criteria for user being logged in network wide?

  • immanence


    I opened a thread to ask about Domain Mapping, but apparently it wouldn't work at all:

    Maybe the update addresses a wider community than MU.

    I'd really have no idea how to lift the code in that plugin and implement it according to my needs. If you're willing to have a go, I'd love to hear any results! I can give you the rest of my rep points :slight_smile:

    On why, I don't need it _as such_. I have three linked pages, one top level domain, two subdomains. I just think it's easier to have users logged in on all levels at once. All are interactive sites that need users to login. Automatic single login just makes it easier for users to surf between sites, upping traffic, perhaps, and overall use.

    It's already a leap that I have a single user table working all three sites. I'm stoked about that! Single login is just the cherry on an already pretty neat cake!

  • Jonathan

    I'd really have no idea how to lift the code in that plugin and implement it according to my needs. If you're willing to have a go, I'd love to hear any results! I can give you the rest of my rep points :slight_smile:

    LOL! You missed the "However, it is going to need some custom coding to get it to work on your setup" Some being it might take some time :wink:

    I think the safer bet is to wait for the next release of domain mapping - masonjames has me biting my nails in anticipation. I have a feeling things are about to get a whole lot better :wink:

    I say I think the safer bet, because when messing around with things that change constantly (security and cookies) you could loose the functionality with a single upgrade of windows.

    Logged in users question: Okay, I understand. Makes sense. And I agree it is just better to have user logged in network wide.

    Maybe the update addresses a wider community than MU

    I think it just might - we will have to see. And I hope it does (it would be a lot safer option for you too - you won't have to worry about wordpress upgrades)

    It's already a leap that I have a single user table working all three sites. I'm stoked about that!

    I agree. In fact I had forgotten how nicely the shared user database system works. It really is nice.