Hi Vladimir, hi David,
I found a code that allow/disallow blocks for specific post types. Is it possible to change that code in a way that I can allow all blocks for admins and only specific blocks for the user roles?
I’m not a coder ;-), maybe something like If(!current_user_can(‘author’) array a,b,c …
That’s the code from https://rudrastyh.com/gutenberg/remove-default-blocks.html#remove_blocks
add_filter( 'allowed_block_types', 'misha_allowed_block_types', 10, 2 );
function misha_allowed_block_types( $allowed_blocks, $post ) {
$allowed_blocks = array(
'core/image',
'core/paragraph',
'core/heading',
'core/list'
);
if( $post->post_type === 'page' ) {
$allowed_blocks[] = 'core/shortcode';
}
return $allowed_blocks;
}
Please stay safe
Wolfgang