User Sync not working for Woocommerce

I have set up a Master and sub site and the sync seems to work if I go into admin and manually update the user. However, My master site is woocommerce and the password reset etc. is handled from the My Account Page. When going through this route for password resets my master user is updated but the change is not propagated to the sub-site.

  • Adam Czajczyk

    Hello Steve,

    I hope you're well today and thank you for your question!

    The User Sync plugin doesn't hook up to any non-standard solutions. It's working with native/core WP functions so if anything affects these functions (which is possible because WP allows "hooking up" to its code in order to alter/enhance it) that may be breaking the code.

    Can you please tell me if this is just a standard WooCommerce install or are you using any special add-ons for it? If you use standard WP tools instead of Woo's to update user, sync works fine and changes are propagated, is that correct?

    Best regards,

  • Steve

    Hi Adam. We are using lots of add-ons. When a user signs up initially it partly works in that the User is created with wp-role of Customer (a woocommerce role) and then appears on the sub-site but when they purchase a subscription and the wp-role changes to Subscriber that isn't synced.
    Similarly any change to the user profile including password is not synced.

    If however, I then go into the user and just click 'Update' the info is synced across to the sub-site.

  • Steve

    Hi. I have set up a test with two sites. The Master is a standard WooCommerce install and the other a standard WP install.

    I created a user on the master and then synced the sub-site; the user was copied over successfully:slight_smile:

    However, I then did a 'Lost Password' on the master site for that user, changed the password and logged in. I expected the sub-site to be synced - its not!

    Surely, this should work?

  • Adam Czajczyk

    Hello Steve!

    I asked about any add-ons/complex settings because if there's "anything" that affects default WP registration flow, that may also affect User Sync.

    Your test with just a standard WooCommerce install seems to confirm that it's that "non-standard flow" that's causing the issue and I'm afraid the only way to overcome that would be to analyze the behavior of the site on code level (I mean Woo and it's add-ons etc, that are related to registration) and then customize the User Sync code to "integrate" with it. That would however be a custom work and quite "case specific".

    As for your "test sites". Password change should be synced so we need to find out why it's not happening there. Could you please:

    1. Enable User Sync debugging - see "Debug Mode" section on this page

    2. Enable WP debugging on both sites (master and sub) by adding following lines to their "wp-config.php" files:

    define('WP_DEBUG', true);
    define('WP_DEBUG_LOG', true);
    define('WP_DEBUG_DISPLAY', false);

    These lines should be located above the "/* That's all, stop editing... */" line in "wp-config.php".

    Then try the "lost password" option again a few times and after that from both sites download:

    - /wp-content/plugins/user-sync/log/error.log file
    - rename them accordingly to "error-m.txt" and "error-s.txt"
    - /wp-content/debug.log file
    - rename them accordingly to "debug-m.txt" and "debug-s.txt"

    and attach to your replay here.

    Hopefully this will give us a clue on the reason of that issue.

    Kind regards,

  • Steve

    Hi Adam.
    I have set up two sites which are as bland as they can be. Standard install 4.7.1, twentyseventeen theme with only 2 plugins activated; WPMU Dev Dashboard and User Synchronization.

    I have enabled debug on both sites but when I add your code for the wp-config.php I get a white screen!

    I went ahead and did a test
    1. Both sites synched and tested that User has same login on both (username and password).
    2. For Master site, followed 'forgot password' link on the wp-login.php screen.
    3. Received reset password email and followed link.
    4. Set new password for Master site User.
    5. Successfully logged into Master site as user with new password.
    6. Attempted login on sub-site for user trying new password; failed.
    7. Logged in to sub-site using old password; success.
    8. Returned to Master and edited User; no change just pressed 'Update'.
    9. Retried step 6. Success.

    It seems that the 'forgot password' route doesn't trigger a synchronisation whereas an edit update does.

    I'm sure you can easily recreate this given that I have removed anything that may interfere. If you want to have full access I can drop the details into one of the sites in the support section if you want. I have granted access in both.

  • Dimitris

    Hello Steve,

    hope you're having a beautiful day! :slight_smile:

    I have enabled debug on both sites but when I add your code for the wp-config.php I get a white screen!

    Could you please access your server through FTP, edit the wp-config.php file, find a line like
    define('WP_DEBUG', false);
    and replace it with the following (if the above line doesn’t exist, simply insert next snippet just above the /* That's all, stop editing! Happy blogging. */ comment)

    // Enable WP_DEBUG mode
    define('WP_DEBUG', true);
    // Enable Debug logging to the /wp-content/debug.log file
    define('WP_DEBUG_LOG', true);
    // Disable display of errors and warnings
    define('WP_DEBUG_DISPLAY', false);
    @ini_set('display_errors', 0);

    Then please go ahead and continue with my colleague's Adam step from his previous reply.

    As for the user syncing issue you described, this may be happening due to WP cron procedures which depends on some actual traffic on your "slave" website (if there's no actual traffic, cron jobs don't trigger).
    You can follow Hoang's proposal here
    in order to remove WP cron and use system cron jobs instead which may be safer to trigger.

    Warm regards,

  • Steve

    I have added the debug code as requested and run the following
    1. Set both sites user to have same password.
    2. Request 'lost password' at Master site.
    3. follow email link and reset password on Mater.
    4. Login to master successfully.
    5. Attempt login fort sub-site; failed
    6. Repeat steps 2-5; still failed
    7. Attempt login to sub-site with original password from step 1.; success!

    Nothing was written to the error.log specified by Adam. I've attached the debug.log files.

  • Predrag Dubajic

    Hi Steve,

    I was doing some extensive testing on my end and I was able to replicate the issue with password reset.

    How User Sync works is that when you make a change to user in admin section it will catch that action and that would be a trigger to start syncing with the subsite.

    However it looks like that reset password from login page doesn't fire required action and sync doesn't start automatically.
    The password is saved properly and if you manually start the sync process from User Sync page it will transfer the new password to subsite.

    I have created bug report for this issue and notified our developers about it.

    Thank you for bringing this up to our attention!

    Best regards,

  • Dimitris

    Hello there Steve,

    hope you're doing good today! :slight_smile:

    I've just tried to replicate this using the default "lost password" page
    and I wasn't able to login to slave site, so I can confirm what you've mentioned.

    I've also tried to add the following line in a MU plugin, still with no avail.
    add_filter( 'user_sync_timeout', function( $timeout ) { return 60; } );

    Having said that, I've already pinged our devs again on this, so they could double check that.
    We'll keep you posted here, as soon as we've got some valuable insights on this.
    Your patience is highly appreciated!

    Warm regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.