Support

Account

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.