Change Text For Password-Protected Posts in WordPress

The default text on password-protected posts in WordPress is: “This post is password protected. To view it please enter your password below:” This function lets you change that text and use your own custom text above the Password form. In the code below, replace line 7 with your own custom message.

function isareplace_password_form($content) {
  global $post;
  if ( !empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH])!=$post->post_password ) {
    $output = '
    <form action="'.get_option('siteurl').'/wp-pass.php" method="post">
      '.__("
This post is password protected. To view it please enter your password below:
").'
       <label for="post_password">Password:</label>
       <input name="post_password" class="input" type="password" size="20" />
       <input type="submit" name="Submit" class="button" value="'.__("Submit").'" />
    </form>
    ';
    return $output;
  }
  else return $content;
}
add_filter('the_content','isareplace_password_form');

We've 2 Responses

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]