Last active
August 29, 2015 13:58
-
-
Save tannerm/10015354 to your computer and use it in GitHub Desktop.
Password protect content.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment