If you ever need to set up a simple password protected area in WordPress, these snippets and plugins might come in handy when you’re hacking through your theme.
I believe this would be the logical approach: you create a main password protected page for your private section and then you create a bunch of child pages under that page. This way you’ll be using native WordPress functionality (page organization and page visibility) for most of your private section.
But you may find that a couple of patches will be in order.
One thing you will not want will be to have to password protect each subpage individually. You’ll just want to set a password for the main parent page and have all its child pages inherit the password protection. This plugin does exactly that.
Similarly, if you decide to use a specific page template for the protected section, it would be ideal to just set the page template to the main parent page and not have to worry about setting it for each of its child pages. This plugin makes subpages inherit their parents template.
You’ll also need a log out link that WordPress doesn’t provide by default. After installing this plugin you’ll be able to use <?php do_action(‘posts_logout_link’); ?> anywhere in your WordPress theme to produce the log out link.
Listing the subpages
Use this code in your theme to display the main parent page as a heading and the child pages below it: http://snipt.org/ugjai6
If you’ve created a page template for your protected pages, you can use the code above in it to give your users a navigation between the subpages.
A couple of snippets for functions.php
Change the default password protected text
The default text on password protected posts or pages is This post is password protected. To view it please enter your password below. Should you wish to change this text, add the following code to your theme’s functions.php file: http://snipt.org/ugjaj0
Change the part where it says “This is my custom text…” in the code above.
Remember: never edit WordPress core files. Either use a plugin or use the functions.php file and filter your changes in from there.
Remove the word “Private:” from the titles
By default the titles of the password protected pages are preceded by the word “Private:” (followed by a colon). To prevent this from happening, add the following filter to your theme’s functions.php file: http://snipt.org/ugjk0