Skip to:
Content
Pages
Categories
Search
Top
Bottom

Keep users from /wp-admin


  • mvaneijgen
    Participant

    @mvaneijgen

    I have a buddypress login form in my sidebar and when a user types in the password or username wrong they get redirected to the /wp-admin

    How can I prevent that from happening?

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

  • mvaneijgen
    Participant

    @mvaneijgen

    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


    bruce7075
    Participant

    @bruce7075

    Hi, need to add above code to which file? Thanks!


    Henry Wright
    Moderator

    @henrywright

    You can put all of your custom BP snippets in your theme’s functions.php. Alternatively, if you plan to swap themes regularly, they can go into your bp-custom.php file (if you don’t have one of these already, you can create one).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Keep users from /wp-admin’ is closed to new replies.
Skip to toolbar