# Make an ACF Field Read-Only

> Shows an ACF field's value in the editor but stops editors changing it, useful for IDs or values filled by an import or integration.

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

## Code

```php
// Field names to lock.
$wpide_acf_readonly_fields = array( 'external_id', 'import_source' );

foreach ( $wpide_acf_readonly_fields as $wpide_acf_readonly_name ) {
    add_filter( 'acf/prepare_field/name=' . $wpide_acf_readonly_name, function ( $field ) {
        if ( is_array( $field ) ) {
            $field['readonly'] = true;
            $field['instructions'] = trim( ( $field['instructions'] ?? '' ) . ' (Read-only)' );
        }

        return $field;
    } );
}
```

## Notes

Works for text, number, email and URL fields. Code can still update the value.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Make an ACF Field Read-Only" 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/
