Im trying to use $_POST method after password reset submit action here is the code
add_action( 'after_password_reset', 'action_function', 10, 2 );
function action_function( $user, $new_pass ){
if (isset( $_POST['password_1'] ) ) {
update_user_meta($user->ID, 'user_pass2', password_hash($_POST['password_1'], PASSWORD_DEFAULT));
}
}
however it doest get fired
any tip?
also the reason I need the password is using for another app credentials for example the following code shows how I use $_POST during profile_update
function my_profile_update( $user_id ) {
// password changed...
if ( ! is_admin() && isset( $_POST['password_1'] ) ) {
update_user_meta($user_id, 'user_pass2', password_hash($_POST['password_1'], PASSWORD_DEFAULT));
global $wpdb;
global $current_user;
$script_db = new wpdb('db', 'pass', 'user', 'localhost');
get_currentuserinfo();
$email = (string) $current_user->user_email;
$password = (string) get_user_meta( $current_user->ID, 'user_pass2', true );;
$query = $script_db->prepare( "SELECT * FROM {$script_db->prefix}np_users WHERE email = %s", $email );
$results = $script_db->get_results($query);
if(count( $results ) > 0) {
$id = $results[0]->id;
$script_db->update('np_users', array(
'password' => $password
),array('id'=>$id));
}
}
}
add_action( 'profile_update', 'my_profile_update' );