Restrict the Code Editor to Administrators
Hides the "Code editor" mode of the block editor from everyone except administrators, so other users only edit visually.
Opens WPIDE on
Code
add_filter( 'block_editor_settings_all', function ( $settings ) {
if ( ! current_user_can( 'manage_options' ) ) {
$settings['codeEditingEnabled'] = false;
}
return $settings;
} );
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.