# Hide the Custom Fields Box From Non-Administrators

> Removes the raw "Custom Fields" box from the editor for everyone except administrators, so editors cannot accidentally change values that plugins and the theme depend on.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: custom-fields, editor, permissions
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-hide-custom-fields-box/

## Code

```php
add_action( 'add_meta_boxes', function () {
    if ( current_user_can( 'manage_options' ) ) {
        return;
    }
    foreach ( get_post_types( array( 'show_ui' => true ) ) as $post_type ) {
        remove_meta_box( 'postcustom', $post_type, 'normal' );
    }
}, 99 );
```

## Notes

Fields shown in proper boxes by plugins such as ACF are not affected.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hide the Custom Fields Box 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/
