Archived topic
Restricting color palette ONLY to glabal colors. Possible?
3 replies · Started by Luca on September 14, 2022
Hi,
Is there a way to restrict the color palette to show only the GP global colors for non-admin users? So that site editors can only use the theme palette and not add other colors?
Thanks,
Hi Luca,
If your using a Child theme, you can try enqueueing your own style in the Block Editor.
For instance, in your Child Theme directory, you create a new file called my-editor-style.css
Then, add this PHP in functions.php:
add_action( 'enqueue_block_editor_assets', function() {
if( !current_user_can( 'manage_options' ) ) {
wp_enqueue_style( 'my-block-editor-styles', get_stylesheet_directory_uri() . "/my-editor-style.css", false,'1.0', 'all' );
}
} );
Your my-editor-style.css should have this code:
.react-colorful {
display: none !important;
}
Hi Fernando,
I was hoping there was a filter for that, but then I will go the CSS way (as it's really 1 line of CSS I will probably use wp_add_inline_style within the anonymous function).
Anyways, thanks a lot.
You're welcome Luca!