Last active
December 13, 2015 21:38
-
-
Save philbirnie/4978757 to your computer and use it in GitHub Desktop.
Password protect custom field types in Wordpress when visibility is set to "Password Protected"
This file contains hidden or 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 | |
//This function evaluates TRUE if the post is not password protected OR the correct password has been supplied. | |
if ( !post_password_required()) | |
{ | |
//Whatever Custom Field(s) you wish to protect | |
the_field("page_content"); | |
} | |
else | |
{ | |
//This will call the password form -- can be customized in functions.php | |
echo get_the_password_form(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment