• Resolved miculgigant

    (@miculgigant)


    Hello!

    Is it possible to request the current password for users that are looking to change their password ? I think this should be the norm when changing a password as it adds an extra layer of security and it’s the way WordPress does it. Can you please include this in future updates ?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Alessandro Tesoro

    (@alessandrotesoro)

    Hi @miculgigant

    Thanks for the suggestion, I might add it in a future update.

    If you require this right now, you can add it using this snippet. Copy and paste the code below into your theme’s functions.php file.

    
    add_filter(
    	'password_change_form_fields',
    	function( $fields ) {
    
    		$fields['password']['current_password'] = [
    			'label'       => 'Current password',
    			'type'        => 'password',
    			'required'    => true,
    			'placeholder' => '',
    			'priority'    => -1,
    		];
    
    		return $fields;
    
    	}
    );
    
    add_filter(
    	'submit_wpum_form_validate_fields',
    	function( $pass, $fields, $values, $form ) {
    
    		if ( $form === 'password' && isset( $values['password']['current_password'] ) ) {
    			$user = get_current_user();
    
    			if ( ! wp_check_password( $values['password']['current_password'], $user->data->user_pass, $user->ID ) ) {
    				return new WP_Error( 'password-validation-failed', 'The password you entered is incorrect.' );
    			}
    		}
    
    		return $pass;
    
    	},
    	10,
    	4
    );
    

    Hope this helps ??

    Thread Starter miculgigant

    (@miculgigant)

    Thank you for your reply. I will def try out the suggested solution!

    Keep up the great work! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Request the current password in order to change the password’ is closed to new replies.