post_password_required
Filter HookDescription
Filters whether a post requires the user to supply a password.Hook Information
File Location |
wp-includes/post-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 911 |
Hook Parameters
Type | Name | Description |
---|---|---|
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. |
WP_Post
|
$post
|
Post object. |
Usage Examples
Basic Usage
<?php
// Hook into post_password_required
add_filter('post_password_required', 'my_custom_filter', 10, 2);
function my_custom_filter($required, $post) {
// Your custom filtering logic here
return $required;
}
Source Code Context
wp-includes/post-template.php:911
- How this hook is used in WordPress core
<?php
906 *
907 * @param bool $required Whether the user needs to supply a password. True if password has not been
908 * provided or is incorrect, false if password has been supplied or is not required.
909 * @param WP_Post $post Post object.
910 */
911 return apply_filters( 'post_password_required', $required, $post );
912 }
913
914 //
915 // Page Template Functions for usage in Themes.
916 //
PHP Documentation
<?php
/**
* Filters whether a post requires the user to supply a password.
*
* @since 4.7.0
*
* @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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post-template.php
Related Hooks
Related hooks will be displayed here in future updates.