Skip to content

Instantly share code, notes, and snippets.

@widoz
Last active April 17, 2022 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save widoz/1139b0a08a269e2ffba7769f50e2e6a0 to your computer and use it in GitHub Desktop.
Save widoz/1139b0a08a269e2ffba7769f50e2e6a0 to your computer and use it in GitHub Desktop.
Gutenberg
<?php
\add_filter('block_editor_settings_all', static function (array $settings): array {
$currentUserRoles = \wp_get_current_user()->roles;
$allowedUserRoles = ['editor', 'administrator'];
$isUserAllowed = (bool)\array_intersect($currentUserRoles, $allowedUserRoles);
if (!$isUserAllowed) {
$settings['canLockBlocks'] = false;
}
return $settings;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment