LLMS_Form_Validator::validate_field_current_password( string $posted_value )

Validate a logged-in users current password


Parameters Parameters

$posted_value

(string) (Required) User-submitted (dirty) value.


Top ↑

Return Return

(WP_Error|boolean) Returns true for a valid submission, otherwise an error.


Top ↑

Source Source

File: includes/forms/class-llms-form-validator.php

	protected function validate_field_current_password( $posted_value ) {

		if ( ! is_user_logged_in() ) {
			return new WP_Error( 'llms-form-field-invalid-no-user', __( 'You must be logged in to update your password.', 'lifterlms' ), $posted_value );
		}

		$user = wp_get_current_user();
		if ( ! wp_check_password( $posted_value, $user->user_pass ) ) {
			return new WP_Error( 'llms-form-field-invalid', __( 'The submitted password was not correct.', 'lifterlms' ), $posted_value );
		}

		return true;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.