Support » Plugin: Getwid - Gutenberg Blocks » disable blocks on multisite network

  • Resolved Jules Colle

    (@jules-colle)


    Hi, I’m deciding on which block library plugin to use for my multisite network. So far, this plugin seems to be the most promising of all. However, there is one problem I’m facing. I want to allow the admins of the subsite to only access a subset of all the blocks.

    I noticed that there is a setting to disable blocks in the settings, which seems to be exactly what I need. But I would like to be able to disable blocks on all websites in my network (There are 50+ websites in the network, so I don’t want to change the settings 50+ times each time I need to make a change)

    If there’s no setting for this, could you let me know if there’s a filter or hook I can use to disable/unregister certain blocks?

    • This topic was modified 3 months, 2 weeks ago by Jules Colle.
Viewing 1 replies (of 1 total)
  • Plugin Support Dmytro

    (@dimned)

    Hi @jules-colle,
    Thank you for using Getwid and for your question. You may try to network deactivate the blocks using this code example:

    const { domReady }  = wp;
    const {
        getBlockTypes,
        unregisterBlockType
    }  = wp.blocks;
    
    domReady( () => {
        const disabledBlocks = [
           'getwid/accordion', // Your register block type [name]
           'getwid/accordion-item',
           'getwid/advanced-heading',
       ];
    
       getBlockTypes().forEach( blockType => {
           if ( disabledBlocks.indexOf( blockType.name ) !== -1 ) {
               unregisterBlockType( blockType.name );
           }
       } );
    } );

    You will need to enqueue the file with the code above in the following way

    wp_enqueue_script( '{your-name}' , get_theme_file_uri( '{your-file-src}' ), array( 'wp-blocks', 'wp-dom' ), '{your-theme-version}', true );

    Let me know if it is helpful.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.