# Hide ACF Fields From Non-Administrators

> Hides the ACF fields you choose in the editor for everyone except administrators, such as internal notes or technical settings.

- Type: PHP
- Runs: Admin only
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: acf, roles, editor
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/acf-hide-field-for-roles/

## Code

```php
// Field names only administrators see.
$wpide_acf_admin_fields = array( 'internal_notes', 'tracking_code' );

foreach ( $wpide_acf_admin_fields as $wpide_acf_admin_field ) {
    add_filter( 'acf/prepare_field/name=' . $wpide_acf_admin_field, function ( $field ) {
        return current_user_can( 'manage_options' ) ? $field : false;
    } );
}
```

## Notes

Hidden fields keep their saved values. Change manage_options to target another role.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide ACF Fields From Non-Administrators" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
