Home › Forums › Quform WordPress › Passwort forgotten form? › Reply To: Passwort forgotten form?
March 16, 2021 at 10:54 am #32702
MGmeiner
Participant
I tried this so far but get a ajax error back
// Check PW field if they match
add_filter('quform_element_valid_6_3', function ($valid, $value, Quform_Element_Password $element) {
if ($value != $element->getForm()->getValue('quform_6_4')) {
$element->addError('Die Passwörter stimmen nicht überein');
$valid = false;
}
return $valid;
}, 10, 3);
// Password reset form - Check if token ist oky and reset password
add_action('quform_post_validate_6', function (array $result, Quform_Form $form) {
if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) {
$rp_key = $_REQUEST['key'];
$rp_login = $_REQUEST['login'];
$user = check_password_reset_key( $rp_key, $rp_login );
$user_new_password = $form->getValue('quform_6_3');
// Parameter checks OK, reset password
if ( $user) {
reset_password( $user, $user_new_password );
wp_redirect( home_url( 'passwort-geaendert' ) );
}
exit;
}
return $result;
}, 10, 2);
- This reply was modified 3 years, 1 month ago by MGmeiner.
- This reply was modified 3 years, 1 month ago by MGmeiner.