Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use this simple HTML loginform in my sidebar. Does anyone have any clever way to make it show the errormessages when you type in wrong password or username?

<form action="<?php echo wp_login_url(get_permalink()); ?>" method="post">
<input type="text" name="log" id="log" style="width:92%; margin-bottom:3px;" value="Username" onfocus="if(this.value=='Username')this.value=''" onblur="if(this.value=='')this.value='Username'" />
<input type="password" name="pwd" id="pwd" style="width:92%; margin-bottom:3px;" value="Password" onfocus="if(this.value=='Password')this.value=''" onblur="if(this.value=='')this.value='Password'" />
<input type="submit" name="submit" class="button" value="Login" />
</form>
share|improve this question

1 Answer 1

Why do you not use the default function wp_login_form() for the login form, example:

global $user_login;

if (is_user_logged_in()) {
    echo __( 'Hello', 'theme_text_domain' ) . $user_login . '<a href="' . wp_logout_url() . '" title="' . __( 'Logout', 'theme_text_domain' ) . '">' . __( 'Logout', FB_BASIS_TEXTDOMAIN ) . '</a>';
} else {
    wp_login_form();
}

the function and his params, more information on the codex

wp_login_form(array(
    'echo' => true,
    'redirect' => site_url($_SERVER['REQUEST_URI']), 
    'form_id' => 'loginform',
    'label_username' => __('Username'),
    'label_password' => __('Password'),
    'label_remember' => __('Remember Me'),
    'label_log_in' => __('Log In'),
    'id_username' => 'user_login',
    'id_password' => 'user_pass',
    'id_remember' => 'rememberme',
    'id_submit' => 'wp-submit',
    'remember' => true,
    'value_username' => ,
    'value_remember' => false
))
share|improve this answer
    
this form just redirects to /wp-login.php to show error message. What I´m trying to do is get the errormessage directly above the form –  Demilio Sep 11 '12 at 13:17
    
the function have the param redirect and you can set a adress, as example the current site, where you login: 'redirect' => site_url($_SERVER['REQUEST_URI']), –  bueltge Sep 11 '12 at 14:33
    
yes, but the messages are still not showing, but I managed to make a page with a custom "login error" text on it, but the best solution would be to include a small message right above the loginform or something. But thanks for the help so far –  Demilio Sep 12 '12 at 11:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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