Skip to content

Instantly share code, notes, and snippets.

@dmjarvis
Created November 27, 2012 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dmjarvis/4153154 to your computer and use it in GitHub Desktop.
Save dmjarvis/4153154 to your computer and use it in GitHub Desktop.
How to override the default WordPress page or post protection form (pre WP 3.4)
<?php
function my_password_form() {
global $post;
$label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
$o = '<form class="protected-post-form" action="' . get_option( 'siteurl' ) . '/wp-pass.php" method="post">
' . __( "To view this protected post, enter the password below:" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" />
</form>
';
return $o;
}
add_filter( 'the_password_form', 'my_password_form' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment