Password syncing not working between Master and Subsite

Hi there, I have user sync installed on http://2016.premierorthoticslab.com/polrestapi/ and a subsite on http://2016.premierorthoticslab.com/pol-front/ .

When I update a password for one of my users on the http://2016.premierorthoticslab.com/polrestapi/ (via the WP password reset mechanism, or the wp-admin reset mechanism). The pol-front user does not seem to have the updated password.

Any help would be greatly appreciated.

  • Vaughan

    Hi,

    Just been looking further at this, it sounds similar to an issue we had last year.

    Do you happen to have woocommerce or other security plugins installed at all? As some of those can take over the password reset scheme.

    If you are running woocommerce for example, can you try the following (it might fix this issue regardless)

    Create a file called wpmudev-user-sync-pw-reset.php

    Copy the following code and place it in this file.

    Make sure <?php is on the very first line of the file with no spaces before it.

    <?php
    if(! class_exists('user_sync_pass_reset') ):
    
        class user_sync_pass_reset{
    
            function __construct(){
    
                add_action( 'plugins_loaded', array($this, 'on_plugins_loaded'));
                add_action('woocommerce_customer_reset_password', array($this, 'on_woocommerce_customer_reset_password'));
            }
    
            function on_woocommerce_customer_reset_password($user){
                if(!class_exists('User_Sync')) return;
                global $user_sync;
                $user_sync->sync_user( $user->ID, $user_sync->options['sub_urls'], false );
            }
    
            function on_plugins_loaded(){
                if(!class_exists('User_Sync')) return;
                global $user_sync;
                if ( "central" == $user_sync->options['status'] ) {
                    add_action( 'password_reset', array( $this, 'user_reset_password' ));
                }
            }
    
            /**
             * Synchronization when user recover/reset password.
             **/
            function user_reset_password( $user, $new_pass ){
                add_filter( "update_user_metadata", array($this, 'user_update_password_nag'), 20, 5 );
            }
    
            function user_update_password_nag( $check, $object_id, $meta_key, $meta_value, $prev_value ){
                global $user_sync;
                $user_sync->sync_user( $object_id, $user_sync->options['sub_urls'], false );
                return $check;
            }
    
         }
        new user_sync_pass_reset;
    endif;

    Then upload this file to /wp-content/mu-plugins/

    If mu-plugins doesn't exist, then create it first. Do this for both master & slave sites.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.