How to Import all users passwords from osCommerce to WordPress (WooCommerece)

Import all users to WordPress with it’s passwords to WordPress using WP All Import

Then just insert this code to functions.php file.

It will override osCommerce password hashes when user logins.

if (!function_exists('wp_check_password')){
    function wp_check_password( $password, $hash, $user_id = '' ) {
        global $wp_hasher;
        $hashArray = explode(':', $hash);
        if (
            strpos('$P$B', $hash) === false &&
            count($hashArray) == 2 &&
            strlen($hashArray[0]) <= 32 &&
            strlen($hashArray[1]) <= 2
        ) {
            $twoCharsPlusPass = $hashArray[1] . $password;
            $check = hash_equals($hash, md5($twoCharsPlusPass) . ':' . $hashArray[1]);
            if ( $check && $user_id ) {
                wp_set_password($password, $user_id);
                $hash = wp_hash_password($password);
                return apply_filters('check_password', $check, $password, $hash, $user_id);
            }
        }
        else if ( strlen( $hash ) <= 32 ) {
            $check = hash_equals( $hash, md5( $password ) );
            if ( $check && $user_id ) {
                wp_set_password( $password, $user_id );
                $hash = wp_hash_password( $password );
            }
            return apply_filters( 'check_password', $check, $password, $hash, $user_id );
        }
        if ( empty( $wp_hasher ) ) {
            require_once ABSPATH . WPINC . '/class-phpass.php';
            $wp_hasher = new PasswordHash( 8, true );
        }    
        $check = $wp_hasher->CheckPassword( $password, $hash );
        return apply_filters( 'check_password', $check, $password, $hash, $user_id );
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *