Home / Admin / Disable Gutenberg Code Editing for Non-Admin Users
Duplicate Snippet

Embed Snippet on Your Site

Disable Gutenberg Code Editing for Non-Admin Users

Prevent non-admin users from using "Edit as HTML" or "Code editor" in the Gutenberg Editor.
WPCode Team
<10
Code Preview
php
<?php
add_filter( 'block_editor_settings_all', function ( $settings ) {
	
	$settings['codeEditingEnabled'] = current_user_can( 'manage_options' );
	return $settings;
} );

Comments

Add a Comment