WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.46k stars 4.18k forks source link

Add specific capability for Navigation permissions #65881

Open stevencamilleri-g2m opened 2 weeks ago

stevencamilleri-g2m commented 2 weeks ago

What problem does this address?

When it comes to the Navigation block, currently editor roles are able to add a navigation block within the block editor but are not able to assign any menus as the navigation block returns the message You do not have the permission to edit Navigation menus. The functionality is not available because by default editor roles have edit_theme_options set to false and without that, the navigation block doesn't allow any access to menus. (Ref: Navigation block user permissions)

Image

The only workaround I have currently is to enable edit_theme_options for editor roles so they have the ability to access menus within the Navigation block, however that would then open up full access to theme options and FSE which I wouldn't want for editors.

What is your proposed solution?

I would suggest creating a specific capability for managing navigation menus. This would allow more granular control over what different roles can do, without giving them access to all theme options. It would also allow the navigation block to be fully functional within the block editor without giving the users access to the site editor (FSE).

getdave commented 1 week ago

@fabiankaegy I think you were looking at permissions at some point relating to template parts. Is there any overlap here with navigation?

In our case it's not the block that needs granular permissions but the act of being able to manipulate a menu.

fabiankaegy commented 1 week ago

@getdave I think this goes much more in depth than what I had looked at before. But I do believe this is a very important topic that we should embrace at some point.

Today the entire site editor is an all or nothing experience. But I do believe that especially in larger organizations there are very different sets of responsibilities that all get combined into one here.

Someone that should be able to update the contents of the site header navigation for example shouldn't necessarily also have the capability to change the layout of the site / the global styles.

It would be very nice if we could split the edit-theme-options capability into more granular sub capabilities which then have a direct affect on which areas of the Site Editor a user can access.

justintadlock commented 1 week ago

This has long been an issue. There's an existing Trac ticket: https://core.trac.wordpress.org/ticket/29213

stevencamilleri-g2m commented 1 week ago

Was there a point where users without edit_theme_options capability were still able to select menus within the navigation block? I'm seeing the screenshot (attached below) in 37454 and I'm unsure if this was a POC or it was actually working that way at some point.

Image

genepine commented 1 week ago

In block themes, the navigation menu cannot be edited with editor privileges. In classic themes, we can use the plugin UserRoleEditor or AdminMenu to give editor privileges and above (i.e. general users) the appropriate privileges for customizing the navigation menu, which allows you to change the order of the menu and change the destination of links. This is not possible with block themes.

getdave commented 1 week ago

We need to make it possible to customise the block based on the standard WordPress permissions system. That would allow those Plugins to work as you describe.