Overrides the result of the post password check for REST requested posts.
Allow users to read the content of password protected posts if they have previously passed a permission check or if they have the edit_post capability for the post being checked.
$requiredboolrequired
$postWP_Postrequired
public function check_password_required( $required, $post ) {
if ( ! $required ) {
return $required;
}
$post = get_post( $post );
if ( ! $post ) {
return $required;
}
if ( ! empty( $this->password_check_passed[ $post->ID ] ) ) {
// Password previously checked and approved.
return false;
}
return ! current_user_can( 'edit_post', $post->ID );
}
| Version | Description |
|---|---|
| 5.7.1 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_posts_controller/check_password_required