• hello,

    I’ve got a custom registration form which works. Then, on this form, I have the “forget password” link. This one is not working very well. The “forget password” form is OK with its design; enter a login or email address to receive an email and to change the password.

    I have 2 cases :

    If the login is empty or false
    If the login is right

    I have the following code :

    <?php>
    //traitement des erreurs de connexion
    $errorlost2 = false;
    if ( !empty( $_POST ) ) {
        $user_login = $_POST['user_login'];
        $user = username_exists( $user_login );
        echo 'user_login =' .$user_login; // renvoi bien le login
        echo 'user =' .$user; // renvoi bien l'ID du user si login exist
        if ( $user == NULL ) {
            header( 'location:lostpassword' );
            $errorlost2 = true;
        } else {
        }
    }?>
        <div id="check-lostpassord" >
        <div class="titre">
            <h1> <img src="<?php echo $cheminsite; ?>/images/lion.png" alt="lion"> <?php echo $lang['TITRE-CONNEXION']; ?>      </h1>
            <div class="titre-underline"> </div>
       </div> 
    
       <div class="connexion-lostpassword">
        <div id="box-lostpassword">
                <p class="message"><?php echo $lang['lostpassword_message']; ?></p>
                </br>
                    <div class="error">
                        <p id="lostpasswordform-erreur2">
                            <?php
                            if ($errorlost2):
                            echo 'TEST';
                                echo $lang['lostpassword_error2'];
                            endif
                            ?>
                        </p>
                    </div>
    
                <!-- http://club-d-affaires.de/wp-login.php?action=lostpassword -->
                <form name="lostpasswordform" class="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post" id="lostpasswordform" >
    
            <br class="clear"></br>
              <p id="text-form">
                <label for="user_login" ><?php echo $lang['lostpassword_login']; ?>*:<br />
                <br class="clear"></br>
                <input type="text" name="user_login" id="user_login" class="input" value="" size="20" /></label>
              </p>
                <br class="clear"></br>
                <br class="clear"></br>
               <?php do_action('login_form', 'resetpass'); ?>
                <p class="submit">
                <input type="submit" name="user-submit" id="wp-submit" class="user-submit" value="<?php echo $lang['lostpassword_envoyer']; ?>" tabindex="1002"/>
                <?php $reset = $_GET['reset']; if($reset == true) {?> </br></br> <p> <?php echo $lang['lostpassword_confirm'];?></p>
                <a href="<?php "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>connexion/?langue=<?php echo $langue; ?>" >
                <h2> <?php  echo $lang['lostpassword_connect']; ?> </h2>    </a>        <?php } ?>
                <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>?reset=true" />
                <input type="hidden" name="user-cookie" value="1" />
                </p>
            </form>
    
           </div> <!-- fin box-connexion -->
        </div> <!-- fin connexion -->
    </div> <!-- fin connexion -->

    The problem is at the beginning of <form> :

    Point 1 – Error message, if login is false or empty, works if I have :

    <form name="lostpasswordform" class="lostpasswordform" action="" method="post" id="lostpasswordform">

    Point 2 – Send an email, with the link to modify the password, works if I have :
    <form name="lostpasswordform" class="lostpasswordform" action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" method="post" id="lostpasswordform" >

    The action=”” is the problem here. How can I have point 1 and point 2 working at the same time?

    Many thanks for your help

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Instead of using wp-login.php to handle the email reset message, let your PHP page do it instead. Some other code patching will be required, but start with calling retrieve_password() instead of username_exists() when handling $_POST values. retrieve_password is a misnomer, it actually checks that the passed user_login field is valid, then sends the reset email.

    For examples of handling errors returned by retrieve_password(), refer to wp-login.php beginning around line 497.

    By doing this, action="" will work for all cases.

    Note that I currently have spotty Internet access and may not be able to respond to further questions for some time. I hope this alone is of some help.

Viewing 1 replies (of 1 total)

The topic ‘Custom "wp_login.php?action=lostpassword"’ is closed to new replies.