post_password_required хук-фильтрWP 4.7.0

Filters whether a post requires the user to supply a password.

Использование

add_filter( 'post_password_required', 'wp_kama_post_password_required_filter', 10, 2 );

/**
 * Function for `post_password_required` filter-hook.
 * 
 * @param bool    $required Whether the user needs to supply a password. True if password has not been provided or is incorrect, false if password has been supplied or is not required.
 * @param WP_Post $post     Post object.
 *
 * @return bool
 */
function wp_kama_post_password_required_filter( $required, $post ){

	// filter...
	return $required;
}
$required(true|false)
Whether the user needs to supply a password. True if password has not been provided or is incorrect, false if password has been supplied or is not required.
$post(WP_Post)
Post object.

Список изменений

С версии 4.7.0 Введена.

Где вызывается хук

post_password_required()
post_password_required
wp-includes/post-template.php 898
return apply_filters( 'post_password_required', $required, $post );
wp-includes/post-template.php 871
return apply_filters( 'post_password_required', false, $post );
wp-includes/post-template.php 876
return apply_filters( 'post_password_required', true, $post );

Где используется хук в WordPress

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1776
add_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1788
remove_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1844
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1882
remove_filter( 'post_password_required', array( $this, 'check_password_required' ) );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 367
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 390
remove_filter( 'post_password_required', array( $this, 'check_password_required' ) );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 506
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );