# Rank Math Box for Editors and Administrators Only

> Removes the Rank Math meta box for users who cannot publish pages, leaving SEO settings to editors and administrators.

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

## Code

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

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

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

## Notes

Rank Math's Role Manager module offers finer control if you enable it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Rank Math Box for Editors and Administrators 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/
