• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WriteNowDesign - Wordpress and Ecommerce Website Design

WordPress, Joomla, Ecommerce Website Design

  • Home
  • Prices/Packages
  • WordPress
  • Services
  • Portfolio
  • Blog
  • About
    • Testimonials
    • Locations
    • Online Payment
  • Contact
  • Show Search
Hide Search

Call 303-907-6133 Email

Hide Custom Fields on Genesis Password Protected Pages

Hide WordPress Custom Fields on Password Protected Genesis Pages

August 30, 2016 by Pat Fortino

I recently built a site using Genesis and Advanced Custom Fields. I’ve done this before so it was fairly straightforward. But on this site, the client wanted the pages with the Custom Fields to be password protected using WordPress’ built in password protection feature. Much to my surprise, on the password protected pages, the main content was hidden, but the Custom Fields were not. The following post explains how to hide WordPress Customs Fields on password protected Genesis pages.

Hiding WordPress Customs Fields on password protected Genesis Pages is fairly easy if you have a code example.

Hide Custom Fields on Genesis Password Protected Pages
WordPress Password Protected Page

Adding the Password Required Code to a Regular WordPress Template

if ( ! post_password_required() ) {
// Enter code to fetch and print Custom Fields here
}

In the code above, you need to wrap the custom field code in the password required if statement. If you are using a regular WordPress template instead of a Genesis template, the above code will work.

Adding the Password Required Code to a Genesis WordPress Template

If you are using a Genesis template, you need to wrap your custom field code in a function so it can be added to a Genesis structural action hook. And you also need to wrap your custom field function code in the password required conditional statement.

Below is a simplified example for Genesis

Below is a detailed example for Genesis

Filed Under: Genesis, Wordpress How To 1 Comment

Previous Post: « Add MP3 to WordPress
Next Post: Change WordPress User Role Capabilities »

Reader Interactions

Comments

  1. Heikki Lahtela says

    April 13, 2019 at 4:51 pm

    Thank you for this!
    You can also put the password check on add_action() to make the code reusable:

    if ( ! post_password_required() ) {
    add_action( ‘genesis_entry_content’, ‘wnd_download’);
    }

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related

Primary Sidebar

Blog Categories

Call Today

Get a Free Quote

303-907-6133

Subscribe to News

News about WordPress, WooCommerce, & Technology

What’s New

  • WPForms Not Sending Notifications
  • Add Terms and Conditions WooCommerce
  • Fix WordPress AMP Validation Errors
  • Use the Classic Editor with Gutenberg Block Editor
  • Add a Message at Top or Bottom of WooCommerce Checkout Page
  • How to Link to a PDF in WordPress

Find Us On…

  • Facebook
  • LinkedIn
  • RSS

Call 303-907-6133 Email

© 2004–2023 · WriteNowDesign · Sitemap · Log in · Return to Top

 

Loading Comments...