Skip to content

Instantly share code, notes, and snippets.

@philbirnie
Last active December 13, 2015 21:38
Show Gist options
  • Save philbirnie/4978757 to your computer and use it in GitHub Desktop.
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"
<?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