froger-me / wp-remote-users-sync

Synchronise users across WordPress websites
GNU General Public License v3.0
71 stars 34 forks source link

Unable to login after imported users #40

Closed ronald-chun closed 1 year ago

ronald-chun commented 3 years ago

Thanks for building the plugin! It is great and the sync feature is helping me a lot. But I am facing a problem when I import some users from Site A to Site B.

When I export the existing users from Site A and then import them to Site B. I cannot log in to Site B by using the user credential from Site A. After some testings, I can use the same user credential to log in to Site B after I updated and saved the user information in Site A.

I don't know am I doing something wrong to cause the situation. Is it okay for me to log in to Site B directly after I imported the users (i.e without any 'Update' on Site A to fire the action)?

Thanks a lot.

Jbiggs-di commented 2 years ago

Were you able to figure this out? I currently have the same issue and am in the process of researching a solution. Thanks!

kyawthetkt commented 2 years ago

@Jbiggs-di I figure it out for my usecase. File - wp-remote-users-sync/inc/class-wprus-import-export.php image

comment this line - $user_data['user_pass'] = wp_generate_password( 16 ); and add the following snippet

try { $wpdb->query( $wpdb->prepare("UPDATE $wpdb->users SET user_pass = %s WHERE ID = %d", $user_data['user_pass'], $maybe_user_id) ); } catch (\Throwable $th) { Wprus_Logger::log( array('message' => __( $th->getMessage(), 'wprus' ), 'data' => null ), 'alert', 'db_log' ); }

And at line 554, add the following column when exported, image

'user_pass' => $user->user_pass,

Not sure it is a good idea but I managed to login when exporting and importing using this way.

froger-me commented 1 year ago

As per plugin's page

User passwords cannot be and are NOT exported.

Please do not do as suggested above, ever. This is a security issue.