Home › Forums › Quform WordPress › Passwort forgotten form?
- This topic has 7 replies, 2 voices, and was last updated 3 years, 8 months ago by Ally.
- AuthorPosts
- March 16, 2021 at 9:10 am #32698MGmeinerParticipant
I just adding at the moment the login form like here -> https://support.themecatcher.net/quform-wordpress-v2/guides/integration/login-form
Can i also build a password reset form?
1. form insert mailadress or username -> User get mail like in wordpress
2. form insert new password (twice)Best regards
March 16, 2021 at 9:57 am #32699AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
March 16, 2021 at 10:14 am #32700MGmeinerParticipantForm works 🙂 got the mail with the link.
Next question 🙂Can i redirect to custom form to reset the pw? with the token?
/wp-login.php?action=rp&key=7Edo4rwxCyA1UM444fw9&login=USERNAME
And checkt the token and if oky reset the pw for the user?
I don’t want that the user are redircted to a wp-login.php page 🙂Attachments:
You must be logged in to view attached files.March 16, 2021 at 10:54 am #32702MGmeinerParticipantI 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, 8 months ago by MGmeiner.
- This reply was modified 3 years, 8 months ago by MGmeiner.
Attachments:
You must be logged in to view attached files.March 16, 2021 at 12:44 pm #32709MGmeinerParticipantOky maybe I think I got it 🙂
add_action('quform_post_validate_6', function (array $result, Quform_Form $form) { if ( 'POST' == $_SERVER['REQUEST_METHOD'] ) { if ( !function_exists( 'check_password_reset_key' ) ) { require_once ABSPATH . WPINC . '/user.php'; } // Hash to validate sending user's password. $key = $_REQUEST['key']; // The user login. $login = $_REQUEST['login']; $user = check_password_reset_key($key, $login); if ( ! $user || is_wp_error( $user ) ) { if ( $user && $user->get_error_code() === 'expired_key' ) { wp_redirect( home_url( 'member-login?login=expiredkey' ) ); } else { wp_redirect( home_url( 'member-login?login=invalidkey' ) ); } exit; } else { $user_new_password = $form->getValue('quform_6_3'); reset_password( $user, $user_new_password ); wp_redirect( home_url( 'passwort-geaendert' ) ); } return; } return $result; }, 10, 2);
- This reply was modified 3 years, 8 months ago by MGmeiner.
March 16, 2021 at 12:46 pm #32711MGmeinerParticipantBut is there something i can do before the form is loading?
So the same thing i did to check if key is ok.So on the moment when the form is loading?
So i can redirect directly if key is not right.March 16, 2021 at 1:02 pm #32713MGmeinerParticipantOky i got it also ->
add_action('quform_pre_display_6', function (Quform_Form $form) { if ( !function_exists( 'check_password_reset_key' ) ) { require_once ABSPATH . WPINC . '/user.php'; } // Hash to validate sending user's password. $key = $_REQUEST['key']; // The user login. $login = $_REQUEST['login']; $user = check_password_reset_key($key, $login); if ( ! $user || is_wp_error( $user ) ) { if ( $user && $user->get_error_code() === 'expired_key' ) { wp_redirect( home_url( 'expiredkey' ) ); } else { wp_redirect( home_url( 'invalidkey' ) ); } exit; } });
March 17, 2021 at 9:42 am #32723AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.