Last active
April 17, 2022 14:12
-
-
Save widoz/1139b0a08a269e2ffba7769f50e2e6a0 to your computer and use it in GitHub Desktop.
Gutenberg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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