Reply To: Passwort forgotten form?

Home Forums Quform WordPress Passwort forgotten form? Reply To: Passwort forgotten form?

#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 4 months, 2 weeks ago by MGmeiner.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy