1

I would like to password protect a page on my blog. Wordpress allows me to give one single password to each protected page. Is there a way to create more than one valid password to access that page?

  • As far I know, it is not possible. What is the purpose of having multiple passwords? Have you thinked about making the pages privated instead of pasword protected or making the pages visible only to logged in users? In that way each user can use his/her own password. – cybmeta Jun 10 '15 at 9:33
  • @cybmeta I'm already using a membership plugin but I cannot use it for that specific purpose. What I want to do is to provide downloads to the buyers of my books without requiring them to subscribe to my website. And I don't want to give the subscribers of my website access to the downloads of my books without buying them. So, I have to keep those two things strictly separated. I would like to have different valid passwords because in that way, I could ask buyers random questions that they can only answer with the book in their hands. – Ralf Glaser Jun 10 '15 at 9:47
  • So, the solution you are looking for is also not useful. Anyone with the password could access to the download link without buying the book. I think you are facing a XY problem. The best solution, from my point of view, is something like Easy Digital Downloads. – cybmeta Jun 10 '15 at 9:49
  • Yes, I know. It's not really an extra level of security. But the only alternative that I see is to manually change password and question regularily. And that's what I would like to avoid. Some functions.php hack to provide more than one password would be an "virtual" extra level, and that would be enough for my purposes. – Ralf Glaser Jun 10 '15 at 10:03
0

In your functions.php you could create a shortcode that shows the link only if a valid password was supplied. This would look like the following code (untested):

function protected_download_handler( $atts ){
    if (in_array(@$_REQUEST['password'], array('password1', 'password2', 'password3')) {
        $return = '<a href="link/to/download/">Download</a>';
    } else {
        $return = '<form action="" method="post">
                   <input type="text" name="password">
                   <input type="submit">
                   </form>';
    }
    return $return;
}
add_shortcode( 'protected_download', 'protected_download_handler' );

And in your page you can use it by adding

[protected_download]

I'm pretty sure that there are also plugins that do what you need.

0

There is a plugin you could use: https://wordpress.org/plugins/multiple-post-passwords/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.