-
Notifications
You must be signed in to change notification settings - Fork 384
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
Update admin screen access #1437
Conversation
…actions Skip showing admin bar item if user cannot validate someone else's post.
@postphotos this fixes the issue you noted when a non-admin tries to access AMP screens. |
Approved Hi @weston, This looked good, when testing it for an administrator, editor, and author. |
@@ -553,14 +553,21 @@ public function render_screen() { | |||
AMP_Options_Manager::check_supported_post_type_update_errors(); | |||
} | |||
?> | |||
<?php if ( ! current_user_can( 'manage_options' ) ) : ?> | |||
<div class="notice notice-info"> | |||
<p><?php esc_html_e( 'You do not have permission to modify these settings. They are shown here for your reference. Please contact your administrator to make changes.', 'amp' ); ?></p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to display this notice.
@@ -1019,12 +1052,19 @@ public static function handle_validate_request() { | |||
if ( ! $post || self::POST_TYPE_SLUG !== $post->post_type ) { | |||
throw new Exception( 'invalid_post' ); | |||
} | |||
if ( ! current_user_can( 'edit_post', $post->ID ) ) { | |||
throw new Exception( 'unauthorized' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to check the capability here.
While the AMP validation screens are generally available to users who can
edit_posts
, in reality this should be tightened up to just administrators, with authors then only able to access theamp_invalid_url
screens with just the posts that they themselves were responsible for creating in the course of creating regular posts.