Skip to content

Commit

Permalink
Fix: Some 403 errors for editor roles.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Dec 19, 2024
1 parent c01cb99 commit d34f9fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,13 @@ const SetAsHomepageModal = ( { items, closeModal } ) => {

export const useSetAsHomepageAction = () => {
const { pageOnFront, pageForPosts } = useSelect( ( select ) => {
const { getEntityRecord } = select( coreStore );
const siteSettings = getEntityRecord( 'root', 'site' );
const { getEntityRecord, canUser } = select( coreStore );
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEntityRecord( 'root', 'site' )
: undefined;
return {
pageOnFront: siteSettings?.page_on_front,
pageForPosts: siteSettings?.page_for_posts,
Expand Down
10 changes: 8 additions & 2 deletions packages/editor/src/components/post-actions/set-as-posts-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ const SetAsPostsPageModal = ( { items, closeModal } ) => {

export const useSetAsPostsPageAction = () => {
const { pageOnFront, pageForPosts } = useSelect( ( select ) => {
const { getEntityRecord } = select( coreStore );
const siteSettings = getEntityRecord( 'root', 'site' );
const { getEntityRecord, canUser } = select( coreStore );
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEntityRecord( 'root', 'site' )
: undefined;

return {
pageOnFront: siteSettings?.page_on_front,
pageForPosts: siteSettings?.page_for_posts,
Expand Down

0 comments on commit d34f9fb

Please sign in to comment.