Passwort forgotten form?

Home Forums Quform WordPress Passwort forgotten form?

This topic is: resolved
  • This topic has 7 replies, 2 voices, and was last updated 3 years ago by Ally.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #32698
    MGmeiner
    Participant

    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

    #32699
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #32700
    MGmeiner
    Participant

    Form 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.
    #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 ago by MGmeiner.
    • This reply was modified 3 years ago by MGmeiner.
    Attachments:
    You must be logged in to view attached files.
    #32709
    MGmeiner
    Participant

    Oky 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 ago by MGmeiner.
    #32711
    MGmeiner
    Participant

    But 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.

    • This reply was modified 3 years ago by MGmeiner.
    • This reply was modified 3 years ago by MGmeiner.
    #32713
    MGmeiner
    Participant

    Oky 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;
            }
    });
    
    #32723
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy