title: Submit WordPress form password programmatically
body: <p>How can I let a user access a WordPress protected page with a URL that will submit the password in the form below?</p>
  
  <p>I want to be able to let a user get to a password protected WordPress page without needing to type the password, so when they go to the page, the password is submitted by a POST URL on page load.</p>
  
  <p>This not intended to be secure in any respect; I'll need to hardcode the password in the URL and the PHP. It's just for simplicity for the user.</p>
  
  <p><strong>Edit 4/19/10:</strong> As per answers below, it's possible to set a cookie directly to allow users to not have to enter a password. Letting search bots in is best done by detecting the user agent and redirecting, as bots aren't going to deal with cookies.</p>
  
  <p><em>This is the form (which is WordPress core code):</em></p>
  
  <pre><code>&lt;form action="http://mydomain.com/wp-pass.php" method="post"&gt;
  
  Password: &lt;input name="post_password" type="password" size="20" /&gt;
  
  &lt;input type="submit" name="Submit" value="Submit" /&gt;&lt;/form&gt;
  </code></pre>
  
  <p><em>This is wp-pass.php (which is WordPress core code):</em> </p>
  
  <pre><code>&lt;?php
  require( dirname(__FILE__) . '/wp-load.php');
  
  if ( get_magic_quotes_gpc() )
      $_POST['post_password'] = stripslashes($_POST['post_password']);
  
  setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);
  
  wp_safe_redirect(wp_get_referer());
  ?&gt;
  </code></pre>