Disable Yoast WordPress SEO for certain roles

The Yoast WordPress SEO plugin offers great control of your WordPress site’s SEO. Unfortunately, the plugin doesn’t define specific capabilities, which suggests you can’t restrict access to the WordPress SEO settings to specific roles. In a multi-user site set up, you may not want your editors or contributors to have access to these settings if they don’t know what they’re doing.

// Returns true if user has specific role 
function check_user_role( $role, $user_id = null ) {
    if ( is_numeric( $user_id ) )
        $user = get_userdata( $user_id );
        $user = wp_get_current_user();
    if ( empty( $user ) )
        return false;
    return in_array( $role, (array) $user->roles );
// Disable WordPress SEO meta box for all roles other than administrator and seo
function wpse_init(){
    if( !(check_user_role('seo') || check_user_role('administrator')) ){
        // Remove page analysis columns from post lists, also SEO status on post editor
        add_filter('wpseo_use_page_analysis', '__return_false');
        // Remove Yoast meta boxes
        add_action('add_meta_boxes', 'disable_seo_metabox', 100000);
add_action('init', 'wpse_init');
function disable_seo_metabox(){
    remove_meta_box('wpseo_meta', 'post', 'normal');
    remove_meta_box('wpseo_meta', 'page', 'normal');

This workaround disables the WordPress SEO meta box and therefore the page analysis columns for all roles aside from ‘administer

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top