#7232
Vladimir
Keymaster

Hi Wolfgang,

You can try this version:


add_filter( 'allowed_block_types', 'misha_allowed_block_types', 10, 2 );
 
function misha_allowed_block_types( $allowed_blocks, $post ) {
    
    $user = wp_get_current_user();
    
    if ( in_array('administrator', $user->roles ) ) {
        // Do not change the list of default blocks for user with administrator role
        return $allowed_blocks;
    }

    if ( in_array('author', $user->roles ) ) {
        // Customize the list of allowed blockes for user with role author
        $allowed_blocks = array(
            'core/image',
            'core/paragraph',
            'core/heading',
            'core/list'
        );    
        return $allowed_blocks;
    }
	  
	return $allowed_blocks;
}