Last active
October 13, 2021 14:39
-
-
Save spivurno/eebad70856ec3be400ccdeface37479a to your computer and use it in GitHub Desktop.
Gravity Wiz // Gravity Forms // Validate Current Password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gravity Wiz // Gravity Forms // Validate Current Password | |
* http://gravitywiz.com/ | |
*/ | |
// update "123" to your form ID, update "6" to your Password field ID | |
add_filter( 'gform_field_validation_1639_1', function( $result, $value ) { | |
$user = wp_get_current_user(); | |
if ( ! wp_check_password( $value, $user->data->user_pass, $user->ID ) ) { | |
$result['is_valid'] = false; | |
$result['message'] = 'Invalid current password. Please try again.'; | |
} | |
return $result; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 This Gist has been migrated to the Gravity Wiz Snippet Library:
https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-validate-current-password.php