post_password_required
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
wp-includes/post-template.php 904
return apply_filters( 'post_password_required', $required, $post );
wp-includes/post-template.php 877
return apply_filters( 'post_password_required', false, $post );
wp-includes/post-template.php 882
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 1780
add_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php 1792
remove_filter( 'post_password_required', '__return_false' );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1858
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 1917
remove_filter( 'post_password_required', array( $this, 'check_password_required' ) );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 374
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 397
remove_filter( 'post_password_required', array( $this, 'check_password_required' ) );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 513
add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );