Password Protect WordPress ACF and other parts of the page.

WordPress allows you to password protect the_content() by default, that’s easy. Here is how to password protect certain parts of the page or Advanced Custom Fields.

Example includes the protected area and the form to access the protected area.

<h1>Members Section</h1>  
         
<?php if ( post_password_required() ) : ?>   
<form method="post" action="<?php bloginfo('wpurl'); ?>/wp-login.php?action=postpass">
        <p>This content is password protected. To view it please enter your password below:</p>
        <input type="password" style="margin:10px 0;" size="20" id="pwbox-<?php the_ID(); ?>" name="post_password"/></label><br/>
        <input type="submit" value="Submit" name="Submit"/></p>
    </form> 
<?php endif; ?>
    
<?php
// password protect Members section fields
if ( !post_password_required() ) { ?>
    <div class="entry-content">
        <?php the_field('page_content'); ?>
    </div><!-- entry content -->
<?php } ?>