Support

Account

Home Forums ACF PRO Exlude fields in acf_form() function Reply To: Exlude fields in acf_form() function

  • 1) I don’t know the status of this. (for anyone that’s interested) My connection is that I answer questions here on this forum, I sometimes report bug that I’ve confirmed through testing to E. I’m part of the support staff, but only as far as the forum is concerned.

    2) Elliot has added a new featured in 5.5 to the acf/prepare_field hook. If you return false from this filter then the field is not rendered. https://www.advancedcustomfields.com/resources/acfprepare_field/.

    I think that this feature is as far as something like the other topic might get. For example, you can add a filter to all fields, have a list of the field keys you don’t want displayed on the front end. See if you’re showing the front end form and if you are and the field is one you don’t want to show then return false.

    
    add_filter('acf/prepare_field', 'my_acf_admin_only_fields');
    function my_acf_admin_only_fields($field) {
      if (is_admin()) {
        return $field;
      }
      $fields = array(
        'field_123',
        'field_abc',
        'field_xyz'
      );
      if (in_array($field['key'], $fields)) {
        return false;
      }
      return $field;
    }