Skip to:
Content
Pages
Categories
Search
Top
Bottom

Keep users from /wp-admin

  • @mvaneijgen

    Participant

    I use [bbp-login] in my sidebar but when you type in your password or username wrong it redirects you to /wp-admin

    How could I keep that from happing or redirect them to a different page?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @mvaneijgen

    Participant

    This works

    // hook failed login
    add_action('wp_login_failed', 'my_front_end_login_fail'); 
     
    function my_front_end_login_fail($username){
        // Get the reffering page, where did the post submission come from?
        $referrer = $_SERVER['HTTP_REFERER'];
     
        // if there's a valid referrer, and it's not the default log-in screen
        if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
            // let's append some information (login=failed) to the URL for the theme to use
            wp_redirect($referrer . '?login=failed'); 
        exit;
        }
    }

    http://www.wpinsite.com/code-snippets/how-to-redirect-wordpress-failed-logins

    @robkk

    Moderator

    glad you solved you own issue.

    @mvaneijgen

    Participant

    Have even more code to also redirect them to a page if a users fills in nothing

    
    add_action( 'wp_authenticate', '_catch_empty_user', 1, 2 );
    
    function _catch_empty_user( $username, $pwd ) {
      if ( empty( $username ) && empty( $pwd )) {
        wp_redirect($referrer . 'http://yourdomain.nl/aanmelden'); 
        exit();
      }
    }
    add_action('wp_login_failed', 'my_front_end_login_fail'); 
     
    function my_front_end_login_fail($username){
        // Get the reffering page, where did the post submission come from?
        $referrer = $_SERVER['HTTP_REFERER'];
     	
        // if there's a valid referrer, and it's not the default log-in screen
        if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){
            // let's append some information (login=failed) to the URL for the theme to use
            wp_redirect($referrer . 'http://yourdomain.nl/aanmelden'); 
        exit;
        }
    }

    Not my code this is all scattered from around the web

    @robkk

    Moderator

    well thanks for finding the code , im sure this will help alot of users who run into the same issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar