0

I'm using a custom Login Form on my wesbite. when user enters a wrong unsername or password, he gets redirected to the default wp-login.php page.

I would like the user to stay on the same page, and add an error message "wrong username or password".

here is my code :

<form method="post" action="<?php echo site_url(); ?>/wp-login.php" id="loginform" name="loginform">

    <div class="form_row"> 

        <input type="text" placeholder="Identifiant" required tabindex="10" size="20" value="" id="user_login" name="log">

    </div>

    <div class="form_row"> 

        <input type="password" placeholder="Mot de passe" required tabindex="20" size="20" value="" id="user_pass" name="pwd">

    </div>

    <div class="form_row"> 

        <div class="flex _left_right">

            <div class="_left">

                <p class="_small forgot_password"><a href="<?php echo site_url(); ?>/wp-login.php?action=lostpassword">Mot de passe oublié ?</a></p>

            </div>

            <div class="_right">

                <div class="rester_connecte">

                <input type="checkbox" tabindex="90" value="forever" id="rememberme" name="rememberme"><p class="_small">Rester connecté</p>

                </div>

            </div>

        </div>

    </div>

    <div class="form_row row_submit"> 

        <input type="submit" tabindex="100" value="Se connecter" id="wp-submit" name="wp-submit">

        <input type="hidden" value="<?php redirect_login_register_url();?>" name="redirect_to">

    </div>

    <div class="form_row text-center"> 

        <p class="_small open_register">Pas encore de compte, cliquez ici pour vous inscrire <img src="<?php echo get_template_directory_uri(); ?>/_/img/arrow_R.png">
        </p>

    </div>

</form>  

is there a way to check if with Ajax the username and the password without reloading the page ?

or

is there a way to redirect the user to the same page and open a modal with an error message ?

thanks for your help

  • I think this might be helpful – nmr Aug 7 '19 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.