Retrieves protected post password form content.
Parameters
Source
function get_the_password_form( $post = 0 ) {
$post = get_post( $post );
$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post">
<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" spellcheck="false" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
';
/**
* Filters the HTML output for the protected post password form.
*
* If modifying the password field, please note that the WordPress database schema
* limits the password field to 255 characters regardless of the value of the
* `minlength` or `maxlength` attributes or other validation that may be added to
* the input.
*
* @since 2.7.0
* @since 5.8.0 Added the `$post` parameter.
*
* @param string $output The password form HTML output.
* @param WP_Post $post Post object.
*/
return apply_filters( 'the_password_form', $output, $post );
}
Hooks
- apply_filters( ‘the_password_form’,
string $output ,WP_Post $post ) Filters the HTML output for the protected post password form.
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |
Example:
And you can use css like :
and hide or modifiy label :
And adapt the button too : :