Skip to:
Content
Pages
Categories
Search
Top
Bottom

Empty login submissions go to wp-login.php page


  • pcgs51
    Participant

    @pcgs51

    I have a login box now in the header of all pages on my site but if the form isn’t filled out and you click submit it doesn’t display an error message, instead it takes you to the wp-login page. How do I avoid that? Is there something I can add to the shortcode that will require information in the form?

    http://www.brucechristian.com/ (temporary url for dubaitrailrunning.com) •
    WordPress v. 3.4.1 •
    bbPress v. 2.1.2

Viewing 2 replies - 1 through 2 (of 2 total)

  • Tanya
    Participant

    @pjtna

    In your functions.php file add this code

    add_action('login_redirect', 'redirect_login', 10, 3);
    function redirect_login($redirect_to, $url, $user) {
    if($user->errors['empty_password']){
    wp_redirect(get_bloginfo('url').'/log-in-error/');
    }
    else if($user->errors['empty_username']){
    wp_redirect(get_bloginfo('url').'/log-in-error/');
    }
    else if($user->errors['invalid_username']){
    wp_redirect(get_bloginfo('url').'/log-in-error/');
    }
    else if($user->errors['incorrect_password']){
    wp_redirect(get_bloginfo('url').'/log-in-error/');
    }
    else{
    wp_redirect(get_bloginfo('url').'/forums/');
    }
    exit;
    }

    I created a page in wordpress called “log in error”, and chose that as the page to be redirected to if you do an incorrect login. In that page I wrote “Your username or password was incorrect. Please try again.” And then I chose bbPress – User Log In as the Template.


    Tanya
    Participant

    @pjtna

    Sorry, the code didn’t come up quite properly. Use this instead:

    http://pastebin.com/XA2BPBhx

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.