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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We’re hard at work on ACF 6.1, and Beta 1 is now available 🚀
— Advanced Custom Fields (@wp_acf) March 16, 2023
This release includes custom post type and taxonomy registration, an improved experience when selecting field types, PHP 8.1 and 8.2 compatibility, and more!
Let’s take a look 🧵https://t.co/Y0WcAT11l4
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.