0

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 :

//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?

2
  • ok, I didn't see that i didn't really understood the use of posting code. Sorry.
    – Timama
    Commented Mar 28, 2015 at 16:17
  • The thing that put problem is at the beginning of <form>. point1 (error message if login false or empty) works if i have action="" point 2 (send an Email with the link to modifie the passsword) works if I have action="<?php echo site_url('wp-login.php?action=lostpassword', 'login_post') ?>" So, the point action:"" is a pb here. I don't know how to have point 1 and point 2 working in the same time. Do you have an idea about this? many thanks for your help Timama
    – Timama
    Commented Mar 28, 2015 at 16:20

1 Answer 1

1

try it:

Runs after the user submits a new password during password reset but before the new password is actually set.

https://codex.wordpress.org/Plugin_API/Action_Reference/password_reset

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.