Change WordPress user roles and capabilities › Forums › New Feature Request › restrict/hide Gutenberg blocks by role
- This topic has 14 replies, 5 voices, and was last updated 1 year, 7 months ago by UserRole Supporter.
-
AuthorPosts
-
15/05/2019 at 04:32 #5669crumpetchrisParticipant
this would be great to have, I love the shortcodes but this would be more intuitive
15/05/2019 at 06:10 #5676VladimirKeymasterThanks for the suggestion. I fully agree with you.
It’s a subject for further development. I will realize this feature this year.13/07/2020 at 15:47 #6954WolfE1963ParticipantHello Vladimir,
did you realize it?
Thanks13/07/2020 at 16:09 #6956VladimirKeymasterHi,
Sorry, this feature is not realized. I still agree that it would be good to add to URE Pro. I can not tell you the date though.
16/10/2020 at 06:30 #7097datendrangParticipantHello!
This Feature would be GREAT! In the new Version of WP the Block Library and the “Gutenberg Templates” are improved. So it would be perfect, do restrict them with permissions for different editor roles.
Give complex Blocks, Block library elements and Templates only to advanced users.
Give simple ones to regular editors.I did a lot of research for this features. No one is really offering it at the moment! So this would be a big improvement for all of us. The only plugin which is pointing in this direction is https://wordpress.org/plugins/advanced-gutenberg/ (but i think it is restricted to their own blocks….)
Also there is no option to share/import/export profiles, or use them over multisite.
What do you think about this feature?
We are building two multisites for 2 non-profit organisations at the moment, where we could need this feature.
=> so if you need some Beta-testing and Feedback, i would be happy to assist you!Best regards
David19/10/2020 at 08:16 #7104VladimirKeymasterHi David!
Thank you for the detailed explanation. I plan to work in this feature.
19/10/2020 at 08:19 #7105datendrangParticipantHello Vladimir, this are GOOD News! Thank you!!!
27/12/2020 at 08:41 #7221WolfE1963ParticipantHi 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
Wolfgang01/01/2021 at 09:20 #7232VladimirKeymasterHi 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; }
14/03/2021 at 09:29 #7418WolfE1963ParticipantDear Vladimir,
so sorry, I overlooked your reply.
IT WORKS!!! What a game changer.
Thank you so much for what you are doing and for your support.
Yours,
Wolfgang15/03/2021 at 09:11 #7423datendrangParticipantHello Vladimir!
yes, that works! Thank you very much! Are you still planning to implement this in your plugin somehow?
Maybe this plugin is somehow helpful to get the list of all used blocks?
best regards
David15/03/2021 at 11:39 #7424VladimirKeymasterHi David!
Thanks for the remind and references on possibly useful code references from existing plugins.
Sure. This feature is a must have for User Role Editor Pro and I still plan to realize it.
I can not tell an exact time when I will be ready to introduce it though. So please wait a little bit more…12/04/2023 at 15:36 #8240UserRole SupporterParticipantHi Vladimir,
If you implement this it would be great to allow us to add blocks to it via their address path eg – “flexblocks/column” etc. This way we can add all the 3rd party blocks we need restricted.
Is it still planned?
Thanks
12/04/2023 at 15:44 #8241VladimirKeymasterHi,
Thanks for suggestion. Yes, it’s still planned and finally will be realized.
12/04/2023 at 16:03 #8242UserRole SupporterParticipantBut I guess it wouldn’t need my last suggestion as it would already know all registered blocks 🙁
-
AuthorPosts
- You must be logged in to reply to this topic.