W3cubDocs

/WordPress

WP_REST_Blocks_Controller::check_read_permission( WP_Post $post ): bool

Checks if a pattern can be read.

Parameters

$postWP_Postrequired
Post object that backs the block.

Return

bool Whether the pattern can be read.

Source

public function check_read_permission( $post ) {
	// By default the read_post capability is mapped to edit_posts.
	if ( ! current_user_can( 'read_post', $post->ID ) ) {
		return false;
	}

	return parent::check_read_permission( $post );
}

Changelog

Version Description
5.0.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_blocks_controller/check_read_permission