WordPress.org

Ready to get started?Download WordPress

Forums

Password Protect Custom Template Page (6 posts)

  1. freshifreshy
    Member
    Posted 4 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!

  2. Shane G.
    Member
    Posted 4 years ago #

    Hi,

    Have a check with this plugin:

    http://wordpress.org/extend/plugins/password-protect-enhancement/

    Thanks,

    Shane G.

  3. freshifreshy
    Member
    Posted 4 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.

  4. natalievi
    Member
    Posted 4 years ago #

    This is exactly what I need. Hopefully there is a solution out there somewhere, I've been searching for days!

  5. mikedev
    Member
    Posted 4 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';
      }
    ?>
  6. brasofilo
    Member
    Posted 4 years ago #

    cool, thx mikedev

Topic Closed

This topic has been closed to new replies.

About this Topic