WordPress at Your Fingertips
function is not described

WP_REST_Posts_Controller::check_password_required() public WP 5.7.1

Override 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 for the post being checked.

{} It's a method of the class: WP_REST_Posts_Controller{}

No Hooks.

Return

true|false. Result of password check taking in to account REST API considerations.

Usage

$WP_REST_Posts_Controller = new WP_REST_Posts_Controller();
$WP_REST_Posts_Controller->check_password_required( $required, $post );
$required(true|false) (required)
Whether the post requires a password check.
$post(WP_Post) (required)
The post been password checked.

Changelog

Since 5.7.1 Introduced.

Code of WP_REST_Posts_Controller::check_password_required() WP 5.7.2

<?php
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 );
}