Roots Discourse

Make wp-password-bcrypt compatible with wp-remote-users-sync (just 1 line)

Hi,
I’m using this plugin (WP Remote Users Sync – WordPress plugin | WordPress.org, Repo: GitHub - froger-me/wp-remote-users-sync: Synchronise users across WordPress websites) and had the problem users couldn’t log into the remote site after registering with the “local” site. Problem was the password not getting passed/the hook of the plugin not fireing.

I managed to fix it by simple adding this line to the wp_password_hash function inside wp-password-bcrypt.php right before the return: do_action('wprus_password', $password);

Could you please update the plugin with the additional line? :slight_smile:

Thanks in advance, best wishes
Julian

1 Like

Glad you got it working, but no we probably won’t add that since then the bcrypt plugin is being coupled to another 3rd party plugin which isn’t a good practice.

It might be useful for wp-password-bcrypt to have its own actions though that people could hook into for additional behaviour like this. Feel free to open a pull request on our repo if that would help with your use case.

Okay, thanks for letting me know. I’m trying but am not (yet) that firm with the WordPress hooks.

So basically I would do something like this?

  1. In my fork of wp-password-bcrypt define a new hook inside the function I want to hook into. So I’d add this at the beginning of the function: do_action('wp_before_set_password', $password, $user_id); (so one can get the password and user_id before the password is set)
  2. In my plugin wait for the hook to be called with something like: add_action('wp_before_set_password', 'myCallback', 10); function myCallback( $pw ) { /* do something with the $pw */ }

Yep that looks about right :+1:

Okay, thanks! Here’s my pull request: Add hook before_wp_hash_password by jwittorf · Pull Request #34 · roots/wp-password-bcrypt · GitHub