# Hide the Yoast Box From Authors and Contributors

> Removes the Yoast SEO meta box for users who cannot publish pages, so only editors and administrators manage SEO settings.

- Type: PHP
- Runs: Admin only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: yoast, admin, roles
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/yoast-hide-metabox-roles/

## Code

```php
// Users without this capability do not see the Yoast box.
$wpide_yoast_cap = 'publish_pages';

add_action( 'add_meta_boxes', function () use ( $wpide_yoast_cap ) {
    if ( current_user_can( $wpide_yoast_cap ) ) {
        return;
    }

    foreach ( get_post_types( array( 'show_ui' => true ) ) as $post_type ) {
        remove_meta_box( 'wpseo_meta', $post_type, 'normal' );
    }
}, 100 );
```

## Notes

Change publish_pages to another capability to widen or narrow who sees the box. In the block editor Yoast's sidebar icon can remain; this removes the main box.

## How to use it

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