Home › Forums › ACF PRO › Password Protect › Reply To: Password Protect
Not knowing the setup. You could either:
1) Use the inbuilt password protection within WP and hope your theme caters for this OR
2) You need to create a custom template:
<?php
/**
* Template Name: Password-Protected Custom Template
*/
?>
<?php get_header(); ?>
<div class="entry-content">
<?php
// STARTS - wrapp your content with this conditional statement
if ( post_password_required() ) :
// if your post is password protected with our Pro version, show our password form instead
echo get_the_password_form();
/* display the password protected content if the correct password is entered */
else :
// display any custom private content
echo 'custom HTML content';
// fetch & print WordPress custom field value via get_post_meta calls
$custom_field_content = get_post_meta( $post->ID, 'key_1', true );
echo $custom_field_content;
// fetch & print ACF fields
the_field( 'acf_introduction_text' );
endif;
// ENDS - hide custom fields with PPWP password protection
?>
</div>
<?php get_footer();?>
You can then assign the template to your page and set the password.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.