freshifreshy
Member
Posted 2 years ago #
I have a custom template that I want to password protect. The problem is that the template doesn't use the content() function, so I need another way of initiating the process.
Basically, I want to require a password for the page, but I don't want the whole template to load if the password hasn't been entered.
Any ideas?
Thanks!
freshifreshy
Member
Posted 2 years ago #
Interesting option, but not quite what I'm looking for.
My template makes a few database queries that I don't want initiated unless the password has been entered.
natalievi
Member
Posted 2 years ago #
This is exactly what I need. Hopefully there is a solution out there somewhere, I've been searching for days!
mikedev
Member
Posted 2 years ago #
Try something like this:
<?php
if ( !post_password_required() ) {
get_footer();
}
?>
Replace get_footer(); with whatever you want to hide until the correct password is entered.
Or this version:
<?php
if ( !post_password_required() ) {
echo 'protected content';
}
?>