title: Redirect after login, Wordpress URLs
body: <p>I'm using the following function to redirect a user after a failed login attempt.  In functions.php, I added:</p>
  
  <pre><code>add_action( 'wp_login_failed', 'inline_login_fail' );
  
  function inline_login_fail( $username ) {
      $referrer = $_SERVER['HTTP_REFERER'];
      if ( !empty($referrer) &amp;&amp; !strstr($referrer,'wp-login') &amp;&amp; !strstr($referrer,'wp-admin') ) {
          if ( !strstr($referrer,'?login=failed') ) { // don’t append twice
          wp_redirect( $referrer . '?login=failed' ); 
          } else {
          wp_redirect( $referrer );
          }
      exit;
      }
  }
  </code></pre>
  
  <p>This works, but the problem is I can't figure out how to parse the '?login-failed'.  When I asked this as a PHP question, they said the URL is malformed.</p>
  
  <p>My URL:  www.site.com/?page_id=57?login=failed</p>
  
  <p>Preferred URL:  www.site.com/?page_id=57&amp;login=failed</p>
  
  <p>Now you would think I could just change the '?' to '&amp;'.  When I do this, it creates an issue if the user is trying to login from the home page and fails.  It creates a URL which is a 404:  "The requested URL /wordpress/&amp;login=failed was not found on this server."</p>
  
  <p>Is there any way to correct this function so it will work with the preferred URL?  That's so I can retrieve the value of whether login has failed, like this:</p>
  
  <pre><code>&lt;?php
  if(isset($_GET['login']) === true and $_GET['login'] === 'failed')
  {
    get_template_part( 'login', 'failed' );
  } else {
    get_template_part( 'login', 'form' );
  }
  ?&gt;
  </code></pre>
  
  <p>Otherwise, I can't figure out how to work with that URL at all.
  Thanks!</p>