Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non Administrator roles are no longer able to change the Template in the Post Editor #58037

Closed
fabiankaegy opened this issue Jan 20, 2024 · 8 comments
Labels
[Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Comments

@fabiankaegy
Copy link
Member

fabiankaegy commented Jan 20, 2024

Description

Since the update to unify the PostTemplatePanel in #56817 any non administrator user roles have lost the ability to switch between available templates.

Before:
CleanShot 2024-01-20 at 14 08 06@2x

After:
CleanShot 2024-01-20 at 14 00 15@2x

Step-by-step reproduction instructions

  1. Make sure your theme supports at least 1 additional custom template besides the default single post template.
  2. Open the post editor with a user account that is an Editor or lower role
  3. See that you are no longer able to switch between the available templates
@fabiankaegy fabiankaegy added [Type] Bug An existing feature does not function as intended [Package] Editor /packages/editor labels Jan 20, 2024
@fabiankaegy
Copy link
Member Author

CC: @youknowriad I believe this is a regression caused in #56817 that I think has a high severity and needs to get fixed before the release of WordPress 6.5

@t-hamano
Copy link
Contributor

This problem doesn't seem to occur with the classic theme. On the other hand, in the block theme, for non-admin users, the panel doesn't seem to render because templateId ( wp.data.select('core/editor').getCurrentTemplateId() ) is null here.

if ( isBlockTheme && !! templateId ) {

@fabiankaegy
Copy link
Member Author

My uneducated guess here is that the custom post type that stores templates is inaccessible for anyone that isn't an admin. And maybe this is as easy as changing the post type access preferences so that any user can view them, but only editors can edit them.

Or the issue is that the post type is already setup that way. But the useSelect hook here doesn't pass the context view along the request.

Either way I think once the access issue is sorted I have a hunch that it will uncover a UI issue because the template locked mode shows the toast notification to tell direct a user to the edit template mode. Which obviously shouldn't happen for any non admin roles since they cannot edit the template.

But as far as I'm aware we never needed to care about that distinction because the site editor where this is coming from was admin only anyways.

@carlomanf
Copy link

There is another related bug at #51886, perhaps both could get fixed together.

@aryanjasala
Copy link

aryanjasala commented Jan 23, 2024

My uneducated guess here is that the custom post type that stores templates is inaccessible for anyone who isn't an admin.

This seems to be the case, the capabilities for all the operations (read, update, delete, create) are being set to edit_theme_options which won't be available to roles other than administrator/super-admin.

I've tried accessing via the editor role and the Template option is not there, but on the other hand, if you add the capability for edit_theme_options to your user, you can access the Template option with any role

@getdave
Copy link
Contributor

getdave commented Jan 30, 2024

Noting that this needs to be (will be) resolved for WordPress 6.5.

@youknowriad has this on his radar and has an idea which is to use the previous UI for non-administrators like we do for classic themes.

@Mamaduka
Copy link
Member

Mamaduka commented Feb 6, 2024

@fabiankaegy, should we close this now that #58485 is merged?

@fabiankaegy
Copy link
Member Author

@Mamaduka yeah let's close it. I still think #58301 is the real solution for the issue where as what we merged is only a hotfix. But the issue described here in this ticket is technically solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants