I found out that I can customize the wp_set_password
function and put my code in it. But it's only executed when a user register through /wp-login.php
.
This was my code:
function wp_set_password( $password, $user_id ) {
// Keep original WP code
global $wpdb;
$hash = wp_hash_password( $password );
$wpdb->update(
$wpdb->users,
array(
'user_pass' => $hash,
'user_activation_key' => '',
),
array( 'ID' => $user_id )
);
wp_cache_delete( $user_id, 'users' );
// and now add your own
$custom_hash = password_hash( $password, PASSWORD_DEFAULT );
update_user_meta($user_id, 'user_pass2', $custom_hash);
}
However I have installed WooCommerce and all three main tasks regarding password are:
- Registration,
- Profile update,
- Password reset.
So this code doesn't help me with that and I've searched for a similar function in WooCommerce, but I couldn't find it. Is there anyway that I can edit WooCommerce like this in my custom plugin and what is the function to do that?