Support

Account

Home Forums ACF PRO Password Protect

Solving

Password Protect

  • Hello, i have a Custom Post Type UI and ACF, i want to protect all custom page with password, but ACF fields always show… how?

  • Are you wrapping your ACF fields inside the password protected area?

    Perhaps you could show your code so we can help?

  • I created a page thanks to CPT IU and added fields to it via ACF. Accordingly, I made the page with a template through an elemental but I do not know how to protect the information from the fields to be visible only with a password (from the options of WordPress)

  • 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.

  • The built-in option protects the content but not what is from the ACF .. How do I make sure it is also protected?

  • I suspect you will need a custom template or to alter the existing template. It sounds like the ACF fields are outside the password protection code – hence the issue.

  • Isn’t there a way I can use them to get them inside so that they can get into the password-protected zone? The other thing that comes to my mind is if there is such a plugin that requires a password when loading the page, but the detail is that I need a different password on each page that is protected.

  • Is the same template used, can you edit it or create a child theme? Perhaps contact the theme developer?

  • I use a child theme and if you give me instructions on how to enter code or make a template I would do it.
    Theme: Hello Elementor Child v1.0

  • To add what @jarvis has already said. If you are calling the_content() anywhere on the page then this will show the password form automatically. So when it comes to ACF you simply need to use

    
    if (!post_password_required()) {
      // show content for ACF fields
    }
    
  • I understand that but where need to add this code for work…

  • You wrap everything that you don’t want show with it if a password is required.

    
    if (!post_password_required()) {
      everything you don't want displayed here when password is required.
    }
    
  • Hey John! and @jarvis

    I’m also having a similar issue. I understand putting the acf content within that snippet but what is the best practice for putting the info in?

    Not sure if I can just put in the whole ACF group key? or even how to list certain fields in this snippet. Can you send an example?

    -Thanks!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.