WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to submit page password via URL parameters (5 posts)

  1. b-cat
    Member
    Posted 4 months ago #

    I'm trying to format a URL link so that it will automatically submit the password for one of my password-protected pages, and will automatically load the page without the user having to manually type the password.

    I'm thinking I need to create a URL something like this:

    http://mysite.com/page.htm?[place various parameters here]

    The variables below might be useful information. The login page for the password-protected page shows the following:

    <form action="http://mysite.com/login?action=postpass" class="post-password-form" method="post">
    <label for="pwbox-1234">  "Password:"
    <input name="post_password" id="pwbox-1234" type="password" size="20">
    <input type="submit" name="Submit" value="Submit">

    Any suggestions on how to correctly format a URL so it will submit the password properly? Can this even be done?

    Many thanks for any suggestions!

  2. catacaustic
    Member
    Posted 4 months ago #

    If you want to pass the password from the form, you need to set the forms method parameter to "get" instead of "post". BUT... if you're doing that you should set the form value for 'action' as a hidden field so that it's passed correctly with the rest of the form values.

    <form action="http://mysite.com/login" class="post-password-form" method="get">
    <label for="pwbox-1234">  "Password:"
    <input name="post_password" id="pwbox-1234" type="password" size="20">
    <input type="submit" name="Submit" value="Submit">
    <input type="hidden" name="action" value="postpass" />
  3. b-cat
    Member
    Posted 4 months ago #

    Sorry...I think you might misunderstand my question.

    I don't want to change the manual login form. For people who need to manually log in, the existing form created by WordPress is fine. (That's the form code I provided above.)

    What I want to do is this: I want to be able to provide selected users with a specific link (for example, I want to send the link in an email) that links directly to the password-protected page, and that link should have the password already included in the URL.

    For example, the URL I might provide to someone might look like this:
    http://mysite.com/page.htm?[place various parameters here]

    The question is: What is the parameter string that needs to follow the "?" question mark at the end of the URL?

    Thanks.

  4. bcworkz
    Member
    Posted 4 months ago #

    You cannot access protected pages that way. The password is sent to the login page for special processing, which sets a cookie if the password is correct. Then the login redirects to the page contained in HTTP_REFERER and the contents are displayed if the cookie is correctly set. Thus the password must come from the page to be opened. Submitting the password from anywhere else will result in a redirect to the wrong location.

    In order to do what you want, you need a custom coded page template that has the ability to check it's own password.

  5. b-cat
    Member
    Posted 4 months ago #

    Ah...okay. That explains a lot. Thanks very much.

Reply

You must log in to post.

About this Topic