[resolved] Custom login page redirects to standard login page on incorrect password (3 posts)

  1. simalamdeveloper
    Posted 2 years ago #


    I am looking to hide the WordPress login page, and create a custom page to log in and log out.

    I currently have a page that allows the user to log in, and one that allows them to log out.

    The problem is when they type in a wrong password they are redirected to the WordPress standard login page and not my own custom one.

    Does anyone know how to solve this problem?

  2. Roman
    Posted 2 years ago #

    you can use wp_redirect() for this.

  3. simalamdeveloper
    Posted 2 years ago #

    Thanks PolshikovRM

    Based on your suggestion I was able to find something that worked for me! I had to edit it a little because it appended the failed login variable each time they attempted to login.

    add_action( 'wp_login_failed', 'my_front_end_login_fail' );  // hook failed login
    function my_front_end_login_fail( $username ) {
       $referrer = $_SERVER['HTTP_REFERER'];  // where did the post submission come from?
       // 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') ) {
    	  $pos = strpos($referrer, '?login=failed');
    		if($pos === false) {
    		 	// add the failed
    		 	wp_redirect( $referrer . '?login=failed' );  // let's append some information (login=failed) to the URL for the theme to use
    		else {
    			// already has the failed don't appened it again
    			wp_redirect( $referrer );  // already appeneded redirect back

    Original Was found on:

Topic Closed

This topic has been closed to new replies.

About this Topic