• Resolved gorebatschov



    I would like to conditionally hide your Custom CSS block panel from Gutenberg, depending on user roles.

    I could easily do this myself with conditionally enqueued CSS if your panel only had a unique CSS class attached to it. Unfortunately it doesn’t at the moment.

    Could you take a look at this and possibly just add a simple static CSS class to the panel you add to the Gutenberg block settings to enable this kind of customization?

    (For example the WP-default Advanced block panel has the CSS class block-editor-block-inspector__advanced in addition to the generic components-panel__body)

    Thanks 🙂

Viewing 1 replies (of 1 total)
  • Plugin Author Hardeep Asrani


    Hey @gorebatschov,

    You can use the following PHP to do that:

    function dequeue_otter_css_for_non_admins() {
        // Check if the current user is not an admin
        if ( ! current_user_can( 'administrator' ) ) {
            // If the user is not an admin, dequeue the 'otter-css' script
            wp_dequeue_script( 'otter-css' );
    add_action( 'enqueue_block_editor_assets', 'dequeue_otter_css_for_non_admins', 100 );

    Let us know if that works.

Viewing 1 replies (of 1 total)
  • The topic ‘Suggestion: Add a CSS class to your panel to enable customization’ is closed to new replies.