post_password_required filter-hookWP 4.7.0

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

Usage

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.

Changelog

Since 4.7.0 Introduced.

Where the hook is called

post_password_required()
post_password_required
wp-includes/post-template.php 881
return apply_filters( 'post_password_required', $required, $post );
wp-includes/post-template.php 854
return apply_filters( 'post_password_required', false, $post );
wp-includes/post-template.php 859
return apply_filters( 'post_password_required', true, $post );

Where the hook is used in WordPress

wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1772
add_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1784
remove_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1798
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1836
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 383
remove_filter( 'post_password_required', array( $this, 'check_password_required' ) );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 498
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );