dcooney / block-manager

Globally manage Gutenberg blocks from a central admin location
https://wordpress.org/plugins/block-manager/
GNU General Public License v2.0
9 stars 1 forks source link

Role Settings #2

Open dcooney opened 3 years ago

dcooney commented 3 years ago

This plugin could become very powerful if it included the option to configure the block access per user-role. source

CodingSamurai commented 3 years ago

Agreed that this would be an essential feature where we'd want to be able to say certain blocks can only be used by certain roles (for instance only Admins can use the Custom HTML block but Editors, Staff & Admins can use the Gallery block).

landwire commented 2 years ago

Are there any plans of implementing this feature request?

dcooney commented 2 years ago

@landwire @CodingSamurai I started prototyping this however Gutenberg errors out when a block is missing. image

The use case here is:

They are still able to save the page but the experience here is a show stopper for this.

Any other ideas?

farukgaric commented 2 years ago

Hello @dcooney

Nice plugin! I tried to limit settings only to Editor role by adding: if ( !current_user_can( 'editor' ) ) { return; } At the beginning of this function: https://github.com/dcooney/block-manager/blob/main/block-manager.php#L84

I believe it's good temporary solution. Of course, role should be retrieved from the settings page where we need select box with all roles.

My five cents! Keep doing great job!

Best Faruk

dcooney commented 1 year ago

@farukgaric Missed your reply. My bad... there is a filter gutenberg_block_manager_user_role that can switch the access role for this plugin.

add_filter( 'gutenberg_block_manager_user_role', 'edit_theme_options' );