Hiding Advanced Custom Fields

Learn how to hide ACF field on the front- or back-end within your WordPress.

Today’s tip of the day is for the Advanced Custom Fields plugin.

In the 2 snippets below you, I show you how to hide an ACF field either on the front-end when using the acf_form() function or in the back-end and limit the field to edited and filled only by users that are administrators.

The Code

add_filter('acf/prepare_field/name=acf_field_slug', function ($field) {
  return false;
}, 10, 1);
add_filter('acf/prepare_field/name=acf_field_slug', function($field) {
  if(is_admin()) {
    return $field;
  return false;
}, 10, 1);

Subscribe to our Newsletter* if you find our content useful and would like to receive regular updates with the latest posts.

* We have a NO SPAM policy so you won't reaceive any meaningless emails from us!

Related Content

6 Expert Gutenberg Tips and Tricks You Should Know

6 expert tips and tricks you probably didn’t know that may improve your workflow and productivity within Gutenberg.


5 SASS Mixins for Your Next Project

Use these SASS mixins to generate and create some utility classes for your next project.


How to Add Sub Domain on Kinsta

Step-by-step guide on how to add a subdomain to your Kinsta account.


Leave a Reply

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

5 Popular Web Page Components Done with Pure CSS
5 SASS Mixins for Your Next Project

Thank you for reading our content. Use the buttons below to spread the love and share How to Add Sub Domain on Kinsta with your followers.