Password protect pages - allow more than one password

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?

Topic password Wordpress

Category Web



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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.