tannerm
4/7/2014 - 5:44 AM

Password protect content.

Password protect content.

<?php
/**
 * Redirect password protected content to it's own file
 */
function tm_password_protect_redirect() {
  // if password is not required or has been entered, continue with standard behavior
  if ( ! post_password_required() ) {
    return;
  }

  // if password is required and is not found, include protected template
  get_template_part( 'protected.php' );
  exit();
}
add_action( 'template_redirect', 'tm_password_protect_redirect', 1 );