Hide Design Controls From Authors and Contributors
Hides color, typography, spacing and border controls in the block editor for authors and contributors, so they focus on writing while editors keep full design control.
Opens WPIDE on
Code
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) {
if ( ! is_user_logged_in() || current_user_can( 'edit_others_posts' ) ) {
return $theme_json;
}
return $theme_json->update_with( array(
'version' => WP_Theme_JSON::LATEST_SCHEMA,
'settings' => array(
'color' => array(
'background' => false,
'text' => false,
'link' => false,
'custom' => false,
'customGradient' => false,
'customDuotone' => false,
),
'typography' => array(
'customFontSize' => false,
'lineHeight' => false,
'dropCap' => false,
'fontStyle' => false,
'fontWeight' => false,
'letterSpacing' => false,
'textTransform' => false,
),
'spacing' => array(
'padding' => false,
'margin' => false,
'blockGap' => false,
),
'border' => array(
'color' => false,
'radius' => false,
'style' => false,
'width' => false,
),
'shadow' => array( 'defaultPresets' => false ),
),
) );
} );
Notes
Users who can edit others' posts (editors, administrators) keep all controls. Styles already applied to blocks remain.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.