views:

44

answers:

2

I'm building a page with a custom template.

The thing is, I need this page to be password protected, or at least accessible to logged in users, but even if I set it as such (Private/Password protected) in the New Pages section in WordPress Administration, it won't display the menu entry nor the content (if Private) or it would show the page contents immediately (if Password protected).

I've read somewhere that the_content() function is what makes this work, but as you can guess, my custom template doesn't use the_content() at all, and it's all based on custom content.

Do you happen to know how can I (re)implement these two options?

+1  A: 

Removed the content of my answer. TheDeadMedic's answer is the correct one.

John P Bloch
This works. Thanks. Now the problem is that some browsers (this is an Intranet) for some reason are able to log in into WordPress Administration, yet they don't work with pages or posts password-protected, it is as it just reloads the page. :'(
KaOSoFt
TheDeadMedic is absolutely right. This is by far less elegant than his solution, which does the same thing much better. I suggest accepting his answer rather than mine.
John P Bloch
+2  A: 

There's a much more elegant and reliable approach to checking if a post is private;

if (post_password_required() {
    // It's protected and they haven't entered a password, so ask for one:
    the_content();

} else {
    // It's not protected or they have entered a password
}
TheDeadMedic
Oh wow, I can't believe I didn't think of this... And I was even looking through source to figure this one out. Definitely looked at what post_password_required() does too. I'm an idiot. Thanks for correcting my absent-mindedness... :/ KaOSoFt, you should accept this answer instead.
John P Bloch
Np - I'm always finding things out about WP!
TheDeadMedic
Thanks a lot to you both. :) PS: I tried it, and it works.
KaOSoFt