Home › Forums › General Issues › Hiding a field on the admin screen › Reply To: Hiding a field on the admin screen
Well, if you’re using ACF pro, there is a hook you can use to remove the field on the back end, but it’s not something that’s documented. I have a plugin that lets you set removal of field by user type. You could use the hook I’m using to remove specific field if is_admin() returns true.
You may need to play with this a bit to get it to work, the ACF hook is acf/get_fields
, like I said, it’s not documented.
You can find it called on line 740 of /api/api-field.php. You need to set the priority > 10 to run after the internal ACF filter.
add_filter('acf/get_fields', 'your_function_name', 20, 2);
function your_function_name($fields, $parent) {
// remove the fields you don't want
return $fields;
}
It’s just a starting point. $fields can be a nested array of fields => sub_fields.
If you want you can see how I do this for user types on line 89 of this file https://github.com/Hube2/acf-user-role-field-setting/blob/master/acf-user-role-field-setting.php
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!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.
— Advanced Custom Fields (@wp_acf) February 23, 2023
👉 https://t.co/3UtvQbDwNmhttps://t.co/wfFEVcXVKc
© 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.