[Resolved] Restrict GenerateBlocks by user role

Home Forums Support Restrict GenerateBlocks by user role

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #1384516

    On a site with many authors, I’d like to force blog posts to only use Gutenberg blocks.

    Is there a way to restrict GenerateBlocks by user role, or to pages only?


    Lead Developer
    Lead Developer

    Hi there,

    Just to confirm, you don’t want any of the blocks to show up/be usable? What if someone without the necessary role opens a page which has GenerateBlocks on it already?


    Hello Tom
    In the same way: More Options > Tools > Block Manager can disable GenerateBlocks. I want to do that so authors can’t turn it back on again.

    If someone with author role writes a POST, I want to hide GenerateBlocks so they are limited to writing their post using Gutenberg blocks.

    If someone with administrator role writes a PAGE, they can use GenerateBlocks.

    So GenerateBlocks will only be used on pages written by users with administrator role.

    GenerateBlocks is incredibly powerful and it lets every author design every post unequally. But on this particular site it’s important that all posts focus on the content, not the design.

    I’m not sure if this is a realistic goal. If it is, it would be useful.

    PS. I’ve been trying out 1.11.0 The combination of GenerateBlocks with hooks and conditional tags really takes GeneratePress into a different league.


    Lead Developer
    Lead Developer

    Not 100% sure this will work, but worth a shot:

    add_filter( 'allowed_block_types', function( $allowed_blocks ) {
        global $post;
        if ( current_user_can( 'manage_options' ) && 'page' === $post->post_type ) {
            return $allowed_blocks;
        return array_diff(
    } );

    Awesome to hear you’re enjoying 1.11! 🙂


    Tried on a local host, adding the code to the end of functions dot php. And tried using your recommend code snippets plugin…

    But I couldn’t get it to work.

    If this is a big job, consider it a possible feature request, not an immediate and pressing need.

    I can get close to what I need via the top right more options button, block manager option.

    PS. I’m not liking 1.11.0, I’m loving it. You mentioned there’s more to come, I can’t wait to see what.

    Lead Developer
    Lead Developer

    I’ll play with this more – I agree that it could be a good feature.

    Thank you! 🙂


    Before Gutenberg I had a “No more than five fancy pages” rule, which served me well.

    I’ll mark the topic as resolved. If you come up with a solution in the short term, I’m sure you can reopen the topic to post more code.


Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.