Developers Tutorial Intermediate 4 min

Lock Down the Block Editor for Clients

Handing a site to a client? Hide the Site Editor, keep colours and fonts on brand, take away the code editor and the extra libraries, and decide who can lock blocks. Ten small snippets for a calmer editor.

TutorialIntermediate15 minTested on WordPress 7.1Updated November 17, 2026

The day you hand a site over, the risk changes. Before, the only person editing was you. After, it’s someone who just wants to update the opening hours and doesn’t know that the Site Editor changes every page at once, or that a custom colour picked today won’t match the brand guide tomorrow.

None of this is about distrust. A focused editor is easier to use, and clients make fewer mistakes when the options in front of them are the ones that make sense for their site.

Give yourself a way back in

Most snippets below check for administrators and leave them alone. The Site Editor lock has a switch in wp-config.php. Keep your own account as administrator and give the client Editor, unless they truly need to install plugins.

Lock the Site Editor and templates

On block themes, anyone who can change theme options can open the Site Editor and edit the header, footer and templates for the whole site. Post editors can also switch into template editing from the sidebar. This turns both off, including the direct link to the Site Editor:

functions.phpPHP
/**
 * Lock the Site Editor and template editing.
 * To unlock temporarily, add define( 'NAHNU_ALLOW_SITE_EDITOR', true ); to wp-config.php.
 */
function nahnu_site_editor_locked(): bool {
	return ! ( defined( 'NAHNU_ALLOW_SITE_EDITOR' ) && NAHNU_ALLOW_SITE_EDITOR );
}

// Remove the Appearance > Editor menu item.
add_action( 'admin_menu', function (): void {
	if ( nahnu_site_editor_locked() ) {
		remove_submenu_page( 'themes.php', 'site-editor.php' );
	}
}, 999 );

// Block direct visits to the Site Editor.
add_action( 'load-site-editor.php', function (): void {
	if ( nahnu_site_editor_locked() ) {
		wp_die( 'The Site Editor is turned off on this site.', 'Site Editor turned off', [ 'response' => 403, 'back_link' => true ] );
	}
} );

// Remove the "Edit template" option from the post editor.
add_filter( 'block_editor_settings_all', function ( array $settings ): array {
	if ( nahnu_site_editor_locked() ) {
		$settings['supportsTemplateMode'] = false;
	}
	return $settings;
} );
Tested on WordPress 7.1 · PHP 8.3Checked November 17, 2026

When you need to make design changes, add define( 'NAHNU_ALLOW_SITE_EDITOR', true ); to wp-config.php. Everything comes back. Remove the line when you’re done. Templates and styles you’ve already built keep working the whole time.

Keep colours and font sizes on brand

By default, every colour and size control has a “custom” option, so any shade of any colour is one click away. Remove the custom picker and size input, and editors choose from your theme’s palette and sizes only:

Snippet

Remove Custom Colours and Font Sizes

Make editors choose from your theme's palette and font sizes only, by removing the custom colour picker and size input.

PHPIntermediate
View

Do the same for drop caps and custom letter spacing, text decoration and font styles on paragraphs:

Snippet

Turn Off Drop Caps and Custom Typography

Remove the drop cap toggle and custom letter spacing, text decoration and font style controls from paragraphs.

PHPBeginner
View

And remove block styles that don’t fit your design, such as the rounded image style:

Snippet

Remove Built-In Block Styles

Remove style options you don't want editors to use, such as the Rounded image style or the Plain quote style.

PHPIntermediate
View
Using theme.json?

On block themes, you can switch off custom colours and font sizes in theme.json instead. The snippet is useful on classic themes, or when you don’t want to edit the theme.

Take away the code editor

The block editor’s Code editor view shows the raw block markup. It’s handy for developers and an easy way for anyone else to break a page. Hide it from everyone except administrators:

Snippet

Hide the Code Editor From Non-Administrators

Remove the "Code editor" option from the block editor for everyone except administrators.

PHPBeginner
View

Decide who can lock blocks

Block locking stops a block being moved or removed. It’s how you protect a layout inside a page. But if editors can lock and unlock blocks too, the protection only lasts until someone clicks unlock:

Snippet

Only Let Administrators Lock Blocks

Remove the Lock option from the block toolbar for everyone except administrators, so editors can't lock or unlock blocks.

PHPBeginner
View

Remove the extras

The block inserter offers plenty of things that come from outside your site. Clients rarely need them, and each is something they can add that you didn’t design for.

Default block patterns, so the inserter only shows patterns you made:

Snippet

Remove Default Block Patterns from the Inserter

Remove WordPress's built-in block patterns and the patterns it downloads from WordPress.org, so the inserter only shows your own.

PHPBeginner
View

The block directory, which offers to install new blocks from WordPress.org when a search finds nothing:

Snippet

Turn Off the Block Directory

Stop the block inserter suggesting and installing blocks from WordPress.org when a search finds nothing.

PHPBeginner
View

Openverse, the library of free images in the Media tab, so editors use your own media:

Snippet

Remove the Openverse Tab From the Media Inserter

Hide the Openverse library of free images from the block inserter's Media tab, so editors only use your own media.

PHPBeginner
View

The font library, so nobody installs new fonts from the Site Editor:

Snippet

Turn Off the Font Library

Stop editors installing and uploading fonts through the Site Editor's font library, keeping your typography consistent.

PHPBeginner
View

Embed variations you never use, like Tumblr or Crowdsignal, to shorten the inserter:

Snippet

Remove Embed Variations You Don’t Use

Clean up the inserter by removing embed blocks for services you never use, such as Tumblr, Reddit or Crowdsignal.

PHPIntermediate
View
You should now see

Log in as the client’s Editor account. Appearance has no Editor item, colour controls show only your palette, there’s no Code editor in the options menu, blocks can’t be locked or unlocked, and the inserter shows only your own patterns and media.

Summary

Lock the Site Editor first, since it affects every page. Then keep colours, sizes and styles on brand, hide the code editor and block locking from non-administrators, and remove the patterns, directories and libraries that come from outside the site. Test with the client’s own role, not your administrator account.

Check your understanding

1Why test these changes with the client’s account rather than yours?
2How do you make design changes after locking the Site Editor?

Was this helpful?

Written by Nahnu Plugins

We build and maintain WordPress plugins. Every guide is tested on a fresh WordPress site before it goes out, and checked again when WordPress updates.

More guides

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only