Home » Web Tutorials » WordPress » How to Lock Blocks in WordPress Gutenberg Editor?

How to Lock Blocks in WordPress Gutenberg Editor?

WordPress Gutenberg editor has plenty of new functionalities compared to the old Classic Editor. Locking individual block is one of the useful features when you have a multi author blog. Some WordPress users confuse this feature with content locking or hiding content behind payment wall. In this article, we will explain how to lock blocks in WordPress Gutenberg and the primary usages for this.

Block Locking in WordPress

The feature was introduced with WordPress 5.9 using block locking API. You can do two things with this:

  • Prevent the locked block from moving
  • Disable deleting of the block

It does not prevent editing (except on reusable blocks as explained below) the content of the block by you or another administrator or author. It has also no impact on the frontend visibility of the locked blocks. The feature was intended to use on templates with full site editing but currently available only for block level. You can check out the WordPress developer section to get the custom function for locking templates.

Locking and Unlocking Single Blocks

Let us show how it works by locking a paragraph block in Gutenberg editor. First create a paragraph and click on the block options (three vertical dots icon showing in the block toolbar) and select “Lock” from the menu.

Lock Option in Block Options
Lock Option in Block Options

This will show a pop-up with the following options:

  • Disable movement – remove the block movement options from the block thus preventing anyone from moving up or down in the page.
  • Prevent removal – disable delete (Remove Paragraph in our case) menu from the block options thus preventing anyone from accidentally deleting the block.
  • Lock all – you can either enable one of the above options or both by selecting lock all check box.
Block Locking Options in Gutenberg
Block Locking Options in Gutenberg

Click “Apply” button to lock the selected block.

Unlocking a Block in WordPress

After you locked a block, the toolbar will not have the move up/down arrows and the menu will not have an option to remove that item. If you want to unlock the block, simply click on the options, and select “Unlock” from the menu. Alternatively, click the lock icon showing in the toolbar.

Unlock Block in WordPress
Unlock Block in WordPress

This will show the same pop-up again where you can uncheck the items and apply your changes.

Locking and Unlocking Grouped Blocks

The best part is that you can lock grouped blocks also. Go to group block options and select “Lock” from the menu. This time you will see an additional option “Apply to all blocks inside”.

  • Enabling this option will lock the group as well as each individual block inside the group. This means you can’t delete or move the blocks inside the group and also the group can’t be deleted or moved up/down.
  • Disabling this option will apply the lock only for the group block. This means you can move the individual blocks inside the group or delete them.
Locking Group Block and Blocks Inside Group in WordPress
Locking Group Block and Blocks Inside Group in WordPress

Using List View for Locking and Unlocking

It is also possible to lock and unlock blocks from the list view. Open the list view and click the options against the block you want to lock. Select “Lock” from the menu and you will see the pop-up. Check lock all or one of the other two options and click “Apply” button.

Lock Block from List View
Lock Block from List View

After applying the lock, you will see a lock icon in the list view. Click on it or select “Unlock” from the options menu to unlock the locked block.

Unlock Block from List View
Unlock Block from List View

Since the page normally contains plenty of blocks, it is not possible to find which blocks are locked and which are not by looking into the content area of the editor. The solution is to use the list view and find all the locked blocks and unlock them if you need.

Lock Reusable Blocks and Restrict Editing

As you can see the problem with locking is that it will not stop editing the content accidentally. Any other author can edit the locked blocks which makes the locking useless if you want to prevent editing. The workaround is to create a reusable block and then apply the locking restrictions. With this method, you will see an additional option for “Restrict editing” which you can use to prevent editing of the locked content.

Locking Reusable Blocks in WordPress
Locking Reusable Blocks in WordPress

Final Words

Though anyone can unlock the block and edit, move, or delete, you can use the locking feature effectively to avoid accidental mistakes. For example, when you have two or three blocks in columns, simply convert that columns to a reusable block and lock it. This will avoid moving or deleting columns as well as individual column within that columns block.

Leave a Comment

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