How to Password Protect Part of a WordPress Post

The question came up about how to Password Protect part of a WordPress post but still allow a description or some other explanatory text to be displayed. It seemed like a pretty straightforward request but it’s not something that WordPress handles right out of the box. You can easily password protect a post, but you can’t see anything so can’t give details about why the rest of the text is hidden. For example you want to provide links to family pictures that only your real family can get to. Or you want to offer photos or a download to specific groups.

In searching around for a solution I came across multiple sites (all related I’m sure) that wanted to rip me off for $50 to $150 for a plugin that would solve the problem. Egad, are you serious?! They wanted to make some sort of user level management system within WordPress that would allow me to charge users or fleece people for money in some other way. That’s not quite what I was going for.

I did however discover a very simple and easy to implement solution that is also free. I tested this out on WordPress 3.0+ and it works fine. It requires a simple change to the WordPress files and uses the MORE function to hide the secondary text with a password. So basically everything before the MORE tag everyone can read. Everything after it requires a password. And this should work from any blogging client.

First off, find /wp-includes/post-template.php in your WordPress install directory.

Find the following text:

$output = get_the_password_form();
return $output;

Replace it with this:

$content = $pages[$page-1];
$content = explode(‘<!–more–>’, $content, 2);
$output = "";
$output .= $content[0];
$output .= get_the_password_form();
return $output;

That’s it. Now you can write your post as you normally would and then if there’s a section you would like to restrict to specific people, just add the MORE tag and then give the post a password. I tried this with Windows Live Writer 2011 and it worked just fine.

I have to say this is a pretty simple solution and unless you have some greater need this should work very well.

This idea was taken from the instructions at this page:

http://www.dagondesign.com/articles/show-the-intro-to-password-protected-posts-in-wordpress

Other articles of interest:

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments
  • How To Disable the Quicken Registration Prompt (10)
    • Jack Woltz: Worked great but now I get update nag which is worse
  • How To Download Movies From Hulu Using Freemake Video Downloader (1)
    • Doomups: I often use allavsoft to download Videos from Hulu on Mac and Windows. And it also can batch and Direclty Download Hulu Videos to MP4, WMV, MOV, AVI, FLV, etc.
  • Why is Daemon Tools Lite triggering Norton Internet Security Anti-Virus? (1)
    • Jaguar: What’s an alternative to using daemon tools? That would be useful to know.
  • Loot Drops for the last few hours of Season Surprise Event – Crime City (1)
  • Topping out with a Trillion Dollars in Crime City (13)
    • Don Pedro: So, just to show how ridiculous things have become, a few weeks ago, I crossed over the 3 Trillion mark in cash. My income has moved to 525.7M IPH. I have both Luggage Lugger buildings upgrading and am working to upgrade the...
    • Tom Offski: Thank you
    • Don Pedro: My income is all from buildings. I have just about every LTB they’ve introduced. I skipped one or two based on their enormous size and terrible income/upgrade costs. Almost all of those buildings are now level 10s. The...
    • Tom Offski: Hey, I’ve been playing sonce 2013, but stopped for a year and a half mid-way. My IPH is 1.05m, and my main source of income is a certain job which gives you 2-7mil for 178 energy… how do you make so much money? Is...
    • Don Pedro: I am very familiar with the time of which you speak. That is when I first came on board as well. There were some good prizes back then such as the decrease in deposit fee. Some of those old buildings are somewhat laughable...
    • Duane Stovall: Yeah 3 of the 5 building upgrades are working on the older regular buildings now. I’ve got all the LTB’s up to level 10. Started playing when FUNZIO owned CC…so was able to purchase every LTB that came...
    • Don Pedro: Upgrading 5 buildings at a time? Damn son! And your IPH is a lot higher than mine. I’ve only got 485 with 3 upgrades at a time, of which I’ve only been using 2. I’ve thought about getting another upgrade...
    • Duane Stovall: I’m up to 517mil iph…just hit my first trillion in the bank. Would have hit a while back…but started a baby syn for my two smaller accounts and maxed out most of the bonuses with the help of one other...
    • Up!: Wow, and here I come with 2m iPH trying to build up a syn.. How long have you been playing? I do think that for normal accounts (without the reduction) its cheaper to leave the money out, being robbed 10% .. would mean in my case 5m...
  • Put another trillion on the fire – Crime City (1)
    • Paul: Im right behind u Scabby at 425 mil iph!! Wish there were better 12 hour buildings coming out
  • New version of Freemake Video Downloader brings back YouTube Playlist downloads (1)
    • ALI: Hi there, I have been trying to download a playlist contains more than 300 episodes but when I copy and paste the link into freemake video downloader app, I can only download max of 100 videos only. Is there anyway to download all...