get_the_password_form

The timeline below displays how wordpress function get_the_password_form has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

//
// Misc.
//
/**
 * Retrieves protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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 core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form 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);
}

WordPress Version: 6.1

//
// Misc.
//
/**
 * Retrieves protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" 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 core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form 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);
}

WordPress Version: 5.8

//
// Misc.
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" 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 core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form 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);
}

WordPress Version: 5.4

//
// Misc.
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" 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 core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form input.
     *
     * @since 2.7.0
     *
     * @param string $output The password form HTML output.
     */
    return apply_filters('the_password_form', $output);
}

WordPress Version: 4.6

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" 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 core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form input.
     *
     * @since 2.7.0
     *
     * @param string $output The password form HTML output.
     */
    return apply_filters('the_password_form', $output);
}

WordPress Version: 4.5

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x('Enter', 'post password form') . '" /></p></form>
	';
    /**
     * Filter the HTML output for the protected post password form.
     *
     * If modifying the password field, please note that the core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form input.
     *
     * @since 2.7.0
     *
     * @param string $output The password form HTML output.
     */
    return apply_filters('the_password_form', $output);
}

WordPress Version: 4.0

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
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" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__('Submit') . '" /></p></form>
	';
    /**
     * Filter the HTML output for the protected post password form.
     *
     * If modifying the password field, please note that the core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form input.
     *
     * @since 2.7.0
     *
     * @param string $output The password form HTML output.
     */
    return apply_filters('the_password_form', $output);
}

WordPress Version: 3.9

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 * @uses apply_filters() Calls 'the_password_form' filter on output.
 * @param int|WP_Post $post Optional. A post ID or post object.
 * @return string HTML content for password form for password protected post.
 */
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" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__('Submit') . '" /></p></form>
	';
    /**
     * Filter the HTML output for the protected post password form.
     *
     * If modifying the password field, please note that the core database schema
     * limits the password field to 20 characters regardless of the value of the
     * size attribute in the form input.
     *
     * @since 2.7.0
     *
     * @param string $output The password form HTML output.
     */
    return apply_filters('the_password_form', $output);
}

WordPress Version: .10

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 * @uses apply_filters() Calls 'the_password_form' filter on output.
 * @param int|WP_Post $post Optional. A post id or post object. Defaults to the current post when in The Loop, undefined otherwise.
 * @return string HTML content for password form for password protected post.
 */
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" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__('Submit') . '" /></p></form>
	';
    return apply_filters('the_password_form', $output);
}

WordPress Version: 3.7

//
// Misc
//
/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 * @uses apply_filters() Calls 'the_password_form' filter on output.
 * @param int|WP_Post $post Optional. A post id or post object. Defaults to the current post when in The Loop, undefined otherwise.
 * @return string HTML content for password form for password protected post.
 */
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" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr__('Submit') . '" /></p>
	</form>
	';
    return apply_filters('the_password_form', $output);
}