Support

Account

Home Forums General Issues ACF fields show up on password protected page

Solved

ACF fields show up on password protected page

  • Hi all,

    How can I tell/instruct ACF to show nothing until a password is given on a password protected page (the default WordPress way to protect a page).
    At this moment, I have a password protected page, but the field where to fill in the password is displayed below the ACF content and all ACF content is shown.
    This might be something simple, but I’m puzzled right now…

  • Ok,

    Figured this one out myself.
    By default WordPress doesn’t protect custom fields, and as such, also custom fields generated by ACF.
    To work around this, all you have to do is wrap this simple if statement around your ACF code in a template file:

    if ( ! post_password_required() ) {
       //All of your code goes here
    }
    

    By magic, WordPress asks the visitor of the page for the password before showing your ACF fields.

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

The topic ‘ACF fields show up on password protected page’ is closed to new replies.