HTML wordpress log-in form + Redirecting a failed log-in back to the custom login page

Log-in form:

<form method=”post” action=”http://www.site.com/wp-login.php” id=”loginform” name=”loginform”>
<p>
User: <input type=”text” tabindex=”10″ size=”20″ value=”” id=”user_login” name=”log”>
<br />
Password: <input type=”password” tabindex=”20″ size=”20″ value=”” id=”user_pass” name=”pwd”><br />
<input type=”submit” tabindex=”100″ value=”Connect” id=”wp-submit” name=”wp-submit”>
<input type=”hidden” value=”http://www.site.com/” name=”redirect_to”>
</p>
</form>

In order to avoid the default wordpress log-in page on failed attempts, add to wp-login.php (in the root directory) at the last php statement before the <!DOCTYPE html … this:

/* if there is some kind on an error, or if the username is simply empty

if (($wp_error->get_error_code()!=”) || ($_REQUEST[‘log’]==”))

{

header(“Location: http://site.com/custom-log-in”);
die();

}

The page to redirect to after login is set in a hidden field, but it might be better to set it up in the php login file.

TO AVOID 404 PAGES USE A COPY FOR wp-login.php (ex. wp-login-custom.php).
wp-login.php IS USED FOR MANY INTERNAL OPERATIONS SUCH AS LOGGING OUT

Leave a Reply

Your email address will not be published. Required fields are marked *