Skip to content

Commit

Permalink
Check user can edit post meta
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 17, 2024
1 parent 1b30f16 commit b1a5a81
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,27 @@ export default {
},
} );
},
lockAttributesEditing() {
lockAttributesEditing( { select, context = {} } ) {
const postId = context.postId
? context.postId
: select( editorStore ).getCurrentPostId();
const postType = context.postType
? context.postType
: select( editorStore ).getCurrentPostType();

// TODO: Check that editing is happening in the post editor and not a template.

// TODO: Check that the custom field is not protected and available in the REST API.

// TODO: Check that the user has the capability to edit post meta.
// Check that the user has the capability to edit post meta.
const canUserEdit = select( coreDataStore ).canUserEditEntityRecord(
'postType',
postType,
postId
);
if ( ! canUserEdit ) {
return true;
}

return false;
},
Expand Down

0 comments on commit b1a5a81

Please sign in to comment.